• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

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
 

maharg

idspispopd
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.
 

maharg

idspispopd
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.
 

Lathentar

Looking for Pants
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