I am trying to read a file containing a list of words and store them in an array. After storing I randomly tried to print the 10th element to ensure that the code did what it's supposed to but I was unsuccessful. I also get the following warning and I don't get what it's telling me:
warning: assignment to ‘char’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] 22 | dict[i][j]=word_scanned;
#include <stdio.h>
#include <stdlib.h>
int main() {
char word_scanned[50];
char dict[102402][50];
int i,j;
FILE *fptr;
if ((fptr = fopen("/usr/share/dict/words", "r")) == NULL) {
printf("Error! opening file\n");
// Program exits if file pointer returns NULL.
exit(1);
}
for(i=0; !feof(fptr); i++){
fscanf(fptr,"%s", word_scanned);
for (j=0; j<50; j++){
dict[i][j]=word_scanned;
}
}
printf("%s\n",dict[9]);
fclose(fptr);
return 0;
}