I am trying to grab multiple lines of input with scanf, all the lines have the same formatting example line:
1, 05:05:04, 1, 1103
the current code I have grabs only one line
scanf(" %d, %d:%d:%d, %d, %d", int1, int2, int3, int4, int5, int6);
I am trying to grab multiple lines of input with scanf, all the lines have the same formatting example line:
1, 05:05:04, 1, 1103
the current code I have grabs only one line
scanf(" %d, %d:%d:%d, %d, %d", int1, int2, int3, int4, int5, int6);
Are you looking for this?
while (scanf("%d,%d:%d:%d,%d,%d",
&int1, &int2, &int3, &int4, &int5, &int6) == 6) {
//use int1, int2, int3, int4, int5, int6
}
This scanfs 2 lines:
scanf("%d, %d:%d:%d, %d, %d\n%d, %d:%d:%d, %d, %d", &int1, &int2...)
You can try using a for loop. So it would be
for (int i =0; i < NumberOfLines;i++)
{
scanf(" %d, %d:%d:%d, %d, %d", int1, int2, int3, int4, int5, int6);
}