include('header.php'); ?>
The following code reads each line from the standard input (stdin) and outputs it on standard out (stdout). By using strings as opposed to char* we don't have to worry about overflowing the input buffer and can handle long lines effortlessly.
///////////////////////
// stdin input example
// using cin.getline
///////////////////////
#include <iostream>
using namespace std;
int main() {
while(cin) {
getline(cin, input_line);
cout << input_line << endl;
};
return 0;
}
% g++ -o stdin_test stdin_test.cpp
./stdin_test