Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started