tags:

views:

90

answers:

2

for example we have created file in c++ how to write content in this file and then output on screen?

+1  A: 

Read this and then come back and ask if you have a more specific question, thanks.

Stephen
i have question no one gave me output why?
Because the question you asked was a very general and to be honest a quite simple question. While we do not demand you spend hours googling for an answer, for something like this a quick google for "c++ write content file" would get you the link I provided in my answer, which is has both code examples and is also a good tutorial on file reading/writing in C++. vtorhonen below actually quoted the examples from that link, so that you don't even have to click on it. If you are still struggling, I can write up an example in my answer for you.
Stephen
A: 

Taken from here.

Writing:

#include <iostream>
#include <fstream>
using namespace std;

int main () {
    ofstream myfile;
    myfile.open ("example.txt");
    myfile << "Writing this to a file.\n";
    myfile.close();
    return 0;
}

Reading:

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main () {
    string line;
    ifstream myfile("example.txt");
    while(getline(myfile,line)) {
        cout << line << endl;
    }
    myfile.close();
    return 0;
}

You should really use Google.

vtorhonen