Question about files I/O

Hello all,

I am new in this forum and I need some help.

I need to make a program, when anything written in the screen is automaticlly written into a file.

I tried using buffers, but I only managed to make 'cout' print to the file and not 'cin'.

please help!
Last edited on
Use std::ofstream to write to a file, not std::cout.
Well you can redirect the standard input, output, and error streams for a program if that's what you want, but it's not C++ that does this, it is the OS.
prgm.exe >out.txt <in.dat 2>err.log
thanks, but it not what I need because it's an assignemnt in C++.

I need to find a way in which anything written in the 'cin' buffer will be written in a file buffer
as well. I tried to assign the buffer of an fstream class to the cin buffer, but it didn't worked =\
Last edited on
I saw it but it didn't help me either.
I will just copy the input char by char.

thanks.
Topic archived. No new replies allowed.