I have an assignment for one of my classes in which we were given a few files to modify to create a program tokenizing text files and inserting the words into a linked list. One of the functions they gave us is this:
Code:
void tokenize_file(FILE *file, list_t *list)
{
char *word;
char buf[101];
buf[100] = 0;
while (!feof(file)) {
/* Skip non-letters */
fscanf(file, "%*[^a-zA-Z0-9'_]");
/* Scan up to 100 letters */
if (fscanf(file, "%100[a-zA-Z0-9'_]", buf) == 1) {
word = strdup(buf);
if (word == NULL)
fatal_error("out of memory");
list_addlast(list, word);
}
}
}
What I am having problems with is to give the function the proper input. I am totally new in C programming and all the pointers etc are throwing me a bit off course here. I tried reading the FAQ, but it didn't help all that much with this specific problem.
What do I have to put in the main function to get this function to run as it should?
Edit: We are supposed to take input (name of the text file(s) to tokenize) from the command line
Thanks,
Jonnar