Reading string from a file
I have been trying to read a string input from a text file. In the code below, I open a file and assign it to FILE * stream. The file passed by argv[1] contains text file. I am trying to figure out a way how I can read the string contents stored into the buffer (curbuff) and then tokenize the string. I guess I can use strtok() to chop the string but I am not sure how would I extract the string out of the buffer. Any help would be appreciated.
------------------------------------------------------------------------
Code:
int cnt;
node *nodes;
int num_nodes = 0;
char curbuff[50];
FILE *stream = fopen(argv[1],"r");
if(stream == NULL)
perror("Invalid Input");
else{
while(!(feof(stream))){
fgets(curbuff,545,stream);
printf("line: %s",curbuff);
if (num_nodes == 0){
nodes = calloc(1,sizeof(node_t));
}
else{
nodes = realloc(humans,num_nodes+1)*sizeof(node_t));
}