The "standalone" getline() function that you used in line 13, reads into a std::string. The getline() function that is a member of the fstream class, that you used in line 14, reads into a C-string. They're two different functions, with the same purpose, but with different types of arguments.I found if I try to read a file into string, only line13 getline(dataF, Crstr) works. line 14 dataF.getline(Crstr,size) flag error no matter how I tried.
I don't know why the people who wrote the C++ standard that introduced std::string didn't simply add an overloaded version of the fstream getline() member function that accepts a std::string.
C++ has occasional little quirks like that. Another example that used to really irritate me (fortunately no longer valid if you use a fairly recent version of C++):
When I taught C++, you had to use a C-string for the file name, when opening a file to create an fstream. If the file name was in a std::string, you had to use the c_str member function to convert it to a C-string:
ifstream myStream; string myFile; // put something into myFile, then... myStream.open (myFile.c_str());
ifstream myStream; string myFile; // put something into myFile, then... myStream.open (myFile);