I want to read a file with 3 lines:
The first one with strings, second with a number and the third with strings again.
Example:
Line 1: bird toy book computer water
Line 2: 2
Line 3: toy water
I have this code, that reads a file, word by word storing them in the word array, and then putting the word into the words 2d array.
char words [5][50];
char word [50];
int i,j;
j = 0;
while( (fscanf(file, "%s", word))!=EOF ){
for(i = 0; i<50; i++){
if(word[i] != NULL){
words[j][i] = word[i];
} else{
break;
}
}
j++;
}
it's working, but it reads all the lines, i want a way to just do this process for the first line, and then store the second line into a int variable and the third line into another 2d array.