lundi 4 juillet 2016

Why won't my program read from a notepad even when copying code from cplusplus.com?


If for some reason you are wondering, I am able to read text to a file with a copy and pasted program from the same site. Thank you for helping me, here is a screenshot for the code and the text file.

The Screenshot

Just in case you don't trust hyperlinks: http://prntscr.com/bjf1cz

The Code

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

        using namespace std;
        int main() {
    string line;
    ifstream myfile("easy.txt");
    if (myfile.is_open())
    {
        while (getline(myfile, line))
        {
            cout << line << 'n';
        }
        myfile.close();
    }

    else cout << "Unable to open filen";

    return 0;
}

Aucun commentaire:

Enregistrer un commentaire