Monday, May 24, 2010

Using the outfile in c++?

I need to send a value to a outfile


that is given by printf("%d ",num) = value by a space division


how do i send it to a file,like this?


outfile %26lt;%26lt; ("a: " );


outfile %26lt;%26lt; printf("%d ",num), %26lt;%26lt; endl;


Hope that is it.

Using the outfile in c++?
Open the file using the constructor on the declaration, like so:


ofstream outfile ("file.txt");





Don't use parenthesis around the text you are trying to print, and if you need to construct a string, do it before hand, like so:





char str[32];


sprintf (str, "a: %d\n", num);


outfile %26lt;%26lt; str;
Reply:first of all make sure you are doing C++ or C....


i ma sorry i have not heared anything like Outfile%26lt;%26lt; in c++


its is like cout%26lt;%26lt;"hello";





i dont know if this is the new version....please check!...


No comments:

Post a Comment