answersLogoWhite

0


Best Answer

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();

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you assign output in C plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are the Example Output of Calculator Program in C plus plus?

example output of c++ calculator


What is the header for basic input or output in C Plus Plus?

For basic input and output in C++: #include


What c plus plus statements assign x the value 12?

x = 12;


How can you view page by page output in c plus plus?

Pipe the output to the MORE command.


What is a plus c?

That depends how much "a" is, and how much "c" is. You can basically assign any value to these variables (letters); then add them up to get "a + c".


Input output function in c plus plus?

input is the &lt;&lt; operator and output is the &gt;&gt; operator


What is used to output data in c plus plus?

You use output devices or streams, typically console screens, printers and files.


How do you get an output of a c plus plus program to be printed?

See sources and related links below.


What machine instruction is used to assign a value to a variable in c plus plus?

MOVE, STORE, LOAD, or something similar, CPU-dependent.


Is cin an output identifier in c plus plus?

No. In C++ with &lt;iostream&gt;, cin is a prefedined class that represents stdin, so it is an input identifier.


How can you get c and c plus plus output statements to work together?

The C and C++ library routines for output might, or might not, include use of different buffers. If they are the same buffer (unlikely) then you can simply intermix the techniques. If they are not the same buffer then you need to do a flush sequence between techniques.


What if -1 is assigned to a unsigned variable in C plus plus?

If you assign -1 to a unsigned variable it will contain the biggest number its able to hold. For example if you assign -1 to a unsigned int it will be 4294967295 as its the biggest number a unsigned int can hold.