// file: example.cc // #include "ll.h" // declare a max line length // #define MAX_LINE_LEN 99999 // program: main // int main(int argc, char** argv) { // declare a variable for the list // struct node *head = NULL; // declare buffer space for a line // char buf[MAX_LINE_LEN]; // open the input file // FILE* fp = fopen(argv[1], "r"); if (fp == (FILE*)NULL) { fprintf(stdout, "<%s>: error opening file (%s)\n", argv[0], argv[1]); } // loop over the file and read lines // while (fgets(buf, MAX_LINE_LEN, fp) != (char*)NULL) { // remove the linefeed // buf[strlen(buf) - 1] = (char)NULL; // fprintf(stdout, "..[%s]..\n", buf); // add an item to the list // insert(&head, buf); } // print the list // printList(head); // exit gracefully // return 0; }