I have the following code
#include <stdio.h>
#include <string.h>
int main()
{
FILE *fp1;
FILE *fp2;
int i,j;
int bin[7], dec[70];
int c;
fp1 = fopen("bin.txt", "r"); //Abrimo el archivo
fp2 = fopen("dec.txt","r");
for (i=0;i<7;i++) {
fscanf(fp1, "%d", &bin[i]);
printf("%d ", bin[i]);
}
for (j=0;j<70;j++) {
fscanf(fp2, "%d", &dec[j]);
printf("%d ", dec[j]);
}
fclose(fp1);
return 0;
}
I need to do some operations with these vectors, clean them and then fill them again with the second line of the text file, but this only reads one line.
I would like to know how to read line by line until the end of the file.
The text file comes as follows
0 0 0 0 0 0 0
0 0 0 0 0 0 1
0 0 0 0 0 1 0
0 0 0 0 0 1 1
0 0 0 0 1 0 0
0 0 0 0 1 0 1
0 0 0 0 1 1 0
0 0 0 0 1 1 1
0 0 0 1 0 0 0
0 0 0 1 0 0 1
0 0 0 1 0 1 0