here is my code so far
Code:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
typedef struct { char l[20]; struct List *next; } List;
List *insertList (char head, List *tail)
{
List *t = calloc (1, sizeof (List));
t -> l = head;
t -> next = tail;
return t;
}
static FILE *open_file (char *file, char *mode)
{
FILE *fp = fopen (file, mode);
if (fp == NULL){
perror ( "Unable to open file" );
exit ( EXIT_FAILURE );
}
return fp;
}
int main (int argc, char *argv[])
{
int ch;
FILE *in;
if ( argc != 3 ) {
fprintf ( stderr, "Usage: %s <readfile1> <writefile2>\n", argv[0] );
exit ( EXIT_FAILURE );
}
in = open_file ( argv[1], "r" );
i am stuck on figuring out how to exactly read in a text file and put every separate word into a list, while ignoring commas.
any ideas? cheers