// copy pairs of doubles from standard input to standard output #include int main( void) { int s; // scanf return status double d1, d2; while( 1) // until end-of-file or error { s = scanf("%lf%lf",&d1,&d2); // try to read two doubles if( s != 2) // could not read two doubles, must be end-of-file or error break; printf( "%g %g\n", d1, d2); } return 0; } /* sample run: $ echo "1.1 2.2 3.3 4.4 5.5 abc 6.6" | ./a.out 1.1 2.2 3.3 4.4 $