not able to work with files

#include<iostream>
#include<fstream>
using namespace std;
int main() {
int a,b,c;
ofstream outfile;
outfile.open("numbers.txt");

cout<<"please enter 3 numbers" <<endl;
cin>>a>>b>>c;
outfile.close();

}


my program doesnt give me any errors.it executes all the steps correctly ,asks me to enter 3 numbers and also creates a file called numbers, but wen i open the file the file doesnt hav any data in it.can someone help please?thanx
closed account (zb0S216C)
You need to place the data in the file. This is achieved with the following code:

 
outfile << a;

std::cout << ..., in English, means: "Send to the console window." outfile << ..., in English, means: "Send to the file."

Wazzak
Topic archived. No new replies allowed.