Monday, 20 May 2013

trying to compile and execute the code below (to read text files), please

trying to compile and execute the code below (to read text files), please

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

void main ()
{
        string STRING;
    ifstream infile;
    infile.open ("names.txt");
        while(!infile.eof) // To get you all the lines.
        {
            getline(infile,STRING); // Saves the line in STRING.
            cout<<STRING; // Prints our STRING.
        }
    infile.close();
    system ("pause");
}

No comments:

Post a Comment