00001 00002 // mycat.C - Write stdin to stdout (to test the g++ piping bug) 00003 00004 # include <stdio.h> 00005 # include <stdlib.h> 00006 # include <iostream.h> 00007 00008 int get_line(istream & str, char * line) 00009 { 00010 str.get(line, 256, '\n'); 00011 if (str.eof()) return 0; 00012 00013 char c; 00014 str.get(c); 00015 return 1; 00016 } 00017 00018 main() 00019 { 00020 char line[256]; 00021 while (get_line(cin, line)) { 00022 00023 cout << line << endl << flush; // Doesn't work! 00024 00025 // fprintf(stdout, "%s\n", line); // Works! 00026 } 00027 fprintf(stdout, "%s\n", line); 00028 fflush(stdout); 00029 }