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
}
这scanfs 2行:
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); }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.