freopen("filename","r",stdin); ->  for taking input from file. ( r :: in
read mode )
freopen("filename","w",stdout) ->  for redirecting output like printf to
file . ( w: in write mode ).

u can also replace file name with argv[1] like  freopen(argv[1],"r",stdin);

basically  when u give input from keyboard , it is first stored in stdin
buffer  , then the programm takes the input from stdin buffer , ex:
scanf("%d",&h);  so input to h will be taken from stdin buffer, but as u r
loading filename to stdin buffer , inputs r taken from file by programm ,
creating illusion that u r inputting value from keyboard , now if u do
printf("hh");  then first "hh" goes to stdout buffer, then it is displayed
in screen from stdout buffer, but now u r STORING the contents of stdout to
filename in w mode.

want some more help ::
http://www.facebook.com/profile.php?id=100000627369242

On Wed, Sep 7, 2011 at 11:57 AM, Ameer Ayoub <[email protected]> wrote:

> Another common technique I've seen with regards to code jam that I've used
> and have seen in some solutions of others is to simply use stdin/stdout and
> redirect the file to stdin and the stdout to a file using the terminal
> (using < and > respectively). Learning to use file streams is definitely
> important if you don't know, but I'm just putting that out there since it's
> a useful technique within the context of google code jam since it quickly
> allows you to view the output in the terminal and redirect it to a file if
> you need to and saves a bit of typing in the solution. (see
> http://www.linuxsa.org.au/tips/io-redirection.html for more information
> about redirection, windows supports something similar as well)
>
> --
> 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.
>

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