Question: need help modifying my program to do this Read multiple lines from the file. Store the lines in memory, preferably in an array. Create a
need help modifying my program to do this
- Read multiple lines from the file.
- Store the lines in memory, preferably in an array.
- Create a function to read the data from memory, and print it to stdout.
#includeint main() { char buffer[1000]; char fileName[20]; FILE *fptr; printf("Enter file name: "); scanf("%s",&fileName); if ((fptr = fopen(fileName, "r")) == NULL) { printf("Error! opening file"); return 0; } // reads text until newline fscanf(fptr, "%[^ ]", buffer); printf("First line in the file is: %s", buffer); fclose(fptr); return 0; }
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
