My professor gave me a C file and I can't really understand it well. It's a program that reads from a text file.
#include <stdio.h>
main(){
int n,m;
char start[30],end[30];
FILE *a;
a=fopen("test.txt","r");
fscanf(a,"%s",&start);
fscanf(a,"%s",&end);
fscanf(a,"%d",&m);
fscanf(a,"%d",&n);
printf("\n%s\n%s\n%d\n%d",start,end,m,n);
char word[n][30];
int i=0;
while(!feof(a)){
fscanf(a,"%s",&word[i]);
i++;
}
for(i=0;i<n;i++)
printf("\n%s",word[i]);
fclose (a);
}
here's the text file:
blah alooa
7 4
hey
boom
stackoverflow
testing
So, I'm wondering what does this char word[n][30]
mean? why does it have [n]
?