jeudi 8 août 2019

Reading .txt into vector by char but not ignoring spaces

I have it reading from the file and pushing it into a vector but it doesn't seem to read the spaces from the message.txt. I'm working a simple program and need the file stored as a vector of chars instead of strings. The message.txt file is just a few word sentence nothing special. Thanks

Has to be chars stored in the vector.

  char c;
    fstream startFile1;
    startFile1.open("message.txt");

    if (startFile1.is_open())
    {
        cout << "File Opened";
    }
    else
    {
        cout << "File Not Opened";
    }

    while (startFile1 >> c)
    {
        originalFile.push_back(c);
    }

    for (int i = 0; i < originalFile.size(); i++)
    {
        cout << originalFile[i];
    }
    cout << originalFile.size();

Aucun commentaire:

Enregistrer un commentaire