Just include these two lines in the beginning of your main function. These
are part of <stdio.h>

freopen( "input.in" , "r" , stdin );
freopen( "output.out" , "w" , stdout );

where "input.in" and "output.out" are input and output files respectively,
in current directory.

After this, normal scanf and printf will be redirected to files :), and by
commenting these two lines, it will be directed to standard i/o.

- AK

On Sun, Aug 8, 2010 at 10:11 PM, Avijit Singh <[email protected]
> wrote:

> hey! i got a doubt actually using our own header files how can we change
> the standard input and output for a program
> for example i want to make file as my standard input and output how can i
> make it.I know that the above thing will work if i used file header file
> like fstream.h and all but i want to use scanf for taking input from the
> file instead of the keyboard so please tell me the way
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-codejam" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-code%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-code?hl=en.
>



-- 
Anil Kishore

-- 
You received this message because you are subscribed to the Google Groups 
"google-codejam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to