Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get information from a scree

Status
Not open for further replies.

mayu03

Programmer
Joined
Oct 3, 2003
Messages
91
Location
US
How to get information from a screen into file?
 
do you mean console?

Ion Filipski
1c.bmp
 
I have some data printed in command line. Is it any easy way to get this data into file?
 
you should wriet in cmdline:
programname.exe > yourfile.txt

Ion Filipski
1c.bmp
 
I know that I can do this way, but I have to write in c++ code. I have a show function void show() which is showing the data. I want to save this data in file. I try this:
fileout<< show();,It didn't work
 
try this:
#include<fstream>
using namespace std;
......
ofstream of(&quot;xx.txt&quot;);
of<< show()<< flush;

Ion Filipski
1c.bmp
 
I am getting this error:
error C2679: binary '<<' : no operator defined which takes
a right-hand operand of type 'void' (or there is no acceptable conversion)
Here is my code:
const char FOUT[]=&quot;C:\\test .dat&quot;;
ofstream outs(FOUT);
if (!outs)
{ cout<< &quot;Unable to Open the file &quot;<<FOUT<< endl;}
else if (outs.is_open())
{
for(int f=0;f<SIZE;f++)
{outs<< cat[f].print()<< flush; }
}
outs.close();
}
 
it means your function print() is void. Change return type to some string type, accumulate all outputs in a string variable, and write them in the file, or put the file as a parameter to function and write inside the function:

1.
string print()
{
str x;
cout<< something;
x += something;
.....
return str;
}
or
2.

void print(ofstrem& f)
{
cout<< something;
f<< something;
.....
}
......

cat[f].print(outs);
outs<< flush;
...

Ion Filipski
1c.bmp
 
Is it possible to get data into file without changing function show from void to string?
 
do you see in the post above:

...
or
2.
...
?
follow 2.


Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top