I am receiving a file as an argument in a C program
Each line has different numbers of integer like this :
1 2 4 5 6
7 8 8 9 10 -1 2 3
12 3 4 -2 2 -3 9 2 4
I want to get the first 2 arguments of each line into some int and all the rest into an array something like this for line #2 :
int a;
int b;
int c[10];
int a = 7;
int b = 8;
int c = [8,9,10,-1,1,2,3]
I am able to obtains the first 2 but I can't make it happens for the array.
Any help would be appreciated
This is what I have right now:
//get line per line until \n
while (fscanf(fp, "%d %d", a, b) != EOF)
while (fscanf(fp,"%d [^\n]", c[n]) != EOF)
n++;
// print each line
for ( int k = 0 ; k < 10; k ++)
printf("%d %d %d \n", a, b, c[k]);