7 7imz Member Jun 8, 2004 #1 well i'm totally new to C... how can i read file on standard input using the scanf fuction? thanks
M maharg idspispopd Jun 8, 2004 #2 Um... are you asking how to use scanf? Because scanf always reads from stdin.
7 7imz Member Jun 8, 2004 #3 no i mean.. if i give it a file, say text.txt... how can i read the contents of that file?
M maharg idspispopd Jun 8, 2004 #5 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.
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.
M maharg idspispopd Jun 8, 2004 #8 Lathentar said: Or you could use C++ and use streams. Click to expand... 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 said: Or you could use C++ and use streams. Click to expand... 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.
L Lathentar Looking for Pants Jun 8, 2004 #9 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. Click to expand... 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.
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. Click to expand... 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.