how can i read file on standard input using scanf?

Status
Not open for further replies.

7imz

Member
well i'm totally new to C... how can i read file on standard input using the scanf fuction? thanks
 
Run it like this:
myprog < file.txt

If you want your program to open the file, use fopen() to open it, then use fscanf instead of scanf.
 
Lathentar said:
Or you could use C++ and use streams.

In all my years of helping people with this sort of stuff I've learned it's generally best to let people burn their hands on the ring.
 
maharg said:
In all my years of helping people with this sort of stuff I've learned it's generally best to let people burn their hands on the ring.

It took a generics programming class for me to realize the true power of streams. Might as well get him started on the right foot, its really easy to get attached to scanf/printf.
 
Status
Not open for further replies.
Top Bottom