To have your program output to a file you must do the following :
First you must write the library that allows the use of files
#include
This will allow you to use the necessary codes to input or output to files
Then in your program you write the following code
ofstream outfile("statistic.txt");
This declares the assigned file for output. Here statistic.txt is the assign file. The program will send the output to that file.
To send the output to the assigned file instead of the screen do the following:
Instead of "cout <<" write out what you put in the previous code "outfile << "
ofstream outfile("statistic.txt");
The bold part determines what you put instead of cout. In this case it was outfile but it can be named whatever you want
Finally at the end of the program you must close it using the following statement:
outfile.close();
Chat with our AI personalities
I guess you mean either input/output/inout/append or binary/text.
Function
True
b+b+b+c+c+c+c =3b+4c
#include <iostream> int main() { std::cout << "1 121 12321 1234321" << std::endl; return 0; }