Back to Programming Languages forum
Because of the many new lines in the test data, I am unable to use the test data as is for input into a C program. Why am I unable to just use argc and argv, without changing the test data first by find/replacing '\n' with ' '? Is there a better way?
I believe the most convenient way for C
program is to use scanf
function for most problems. It read data separated either with spaces or newlines. Something like this:
#include <stdio.h>
int main(void) {
int n, a, b;
scanf("%d", &n);
while (n-- > 0) {
scanf("%d %d", &a, &b);
// do anything with a and b
}
}
it will simply read from the input like this:
3
100 220
911 408
512 111
Hope this helps. With argc
and argv
the problem is that posix limit for it is usually as low as 4096
bytes.