How to copy a .txt file to a char array in c++

后端 未结 5 888
忘了有多久
忘了有多久 2020-11-27 17:26

Im trying to copy a whole .txt file into a char array. My code works but it leaves out the white spaces. So for example if my .txt file reads \"I Like Pie\" and i copy it to

5条回答
  •  时光说笑
    2020-11-27 18:03

    A much simpler approach would be using the get() member function:

    while(!myfile.eof() && i < arraysize)
    {
        myfile.get(array[i]); //reading single character from file to array
        i++;
    }
    

提交回复
热议问题