defaulting ifstream variable to standard input
Hi peeps
Can anyone tell me what must be a fairly standard incantation?
About a decade ago I wrote
Code:
ifstream fin;
if (NULL == inputStream)
{
fin.attach(0);
inputStream = "stdin";
}
else
{
fin.open(inputStream, ios::in);
}
inputStream is NULL unless a filename has been specified on the command line. The attach() function that was available with that compiler allowed me to use this program as part of a pipeline.
Code:
who -a | sortByDate
or
I haven't really used C++ since then and the attach() function seems to have been an extension that isn't available today. I can't simply do can I?