How to Read from a Text File, Character by Character in C++

后端 未结 8 1819
孤街浪徒
孤街浪徒 2020-12-06 10:17

I was wondering if someone could help me figure out how to read from a text file in C++, character by character. That way, I could have a while loop (while there\'s still te

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-06 10:47

    Re: textFile.getch(), did you make that up, or do you have a reference that says it should work? If it's the latter, get rid of it. If it's the former, don't do that. Get a good reference.

    char ch;
    textFile.unsetf(ios_base::skipws);
    textFile >> ch;
    

提交回复
热议问题