Using Code to Write to a File but Not Record a Count - C++ File Stream

C++ examples for File Stream:stream

Description

Using Code to Write to a File but Not Record a Count

Demo Code

#include <iostream> 
#include <fstream> 
#include <string> 

using namespace std; 

void WriteFile(string filename, int count, int start) 
{ 
    ofstream outfile(filename.c_str()); 
    int i; // w w  w  .  j  a  v a2  s .  co m
    for (i=0; i<count; i++) 
    { 
        outfile << start + i  << endl; 
    } 
    outfile.close(); 
} 

int main() 
{ 
    WriteFile("../nums1.txt", 5, 100); 
    WriteFile("../nums2.txt", 6, 200); 
    return 0; 
}

Related Tutorials