I have to read in a file such as
apple
grape
banana
And store it into a string, but fgets only reads up to the newline and stops, so its only reading in apple.
How do I get around this? Or how can I store the three words all as separate strings?
char* readFile(const char *fileName)
{
FILE *inFile;
inFile=fopen(fileName, "r");
char **stringInFile;
stringInFile = malloc(sizeof(char*)*50);
char *data = fgets(stringInFile,50,inFile);
printf("%s", data);
fclose(inFile);
return data;
}
This is all in C btw.