Program must be in C (not C++ or java)
I am having issues writing a program to read in a file namedtest store it into an array and then print each word.
test contains 10 words some with different spaces examplebelow
first second third
banana apple
rockstar monster surge test program
thanks in advance
Answer
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *fptr = fopen(“file.txt”,”r”);
char strings[10][20];
int count = 0;
while( fscanf(fptr, “%s”, strings[count]) != EOF )
count++;
int i=0;
for(; i<10; i++)
printf(“%sn”, strings[i]);
return 0;
}
/*OUTPUT
first
second
third
banana
apple
rockstar
monster
surge
test
program
*/
#include <stdio.h> 1 2 #include
OR
OR