C++ ofstream Write int value to text file

Description

C++ ofstream Write int value to text file

#include <iostream> 
#include <fstream> 

using namespace std; 

int main() /*from  w w w .j av a  2s.c o m*/
{ 
    ofstream outfile("outfile.txt"); 
    outfile << "I'm in a file!" << endl; 
    int x = 200; 
    outfile << x << endl; 
    outfile.close(); 
    return 0; 
}



PreviousNext

Related