streambuf *buf = cin.rdbuf(); // keep the cin buffer to restore it
ifstream file ( "something"); // create the file
cin.rdbuf( file.rdbuf() ); // redirect input
// use cin - it will read from the file -
cin.rdbuf ( buf ); // reset cin buffer to the previous one
What is the point of that anyway when you can just manipulate the ifstream directly as though it were an iostream? The interface and operators are largely the same.
I'm not sure if this is what you mean, but in a *nix OS, on the command line you can pipe or redirect another programs output into your own program. For example, "cat file | ./yourprogram".
All your program has to do is read from cin to access the input.