Okay, I have created an array str as a test. The text file contains:
How would I copy the file into the array? I have tried using fgets:
Should I be using a different function?
while(fgets(ary,100,fp1) != NULL)
Hey guys, I kind of figured it out. Here is my code:
I am using fscanf to read in the file into the array. I now need to dynamically allocate memory for the contents of the file. Going to brush up on dynamic memory allocation. Do you have an suggestions regarding which allocation method I should use to find the exact size of the text file?
if((fp1=fopen(filename, "r")) == NULL)
printf("Cannot open %s for reading.", filename);
fscanf(fp1, "%s", ary[i]);