text_data = {apple \n
grapes \n
straberry};
FILE *fp; int i; char ch;
std::string DataVal;
std::ifstream in("D:\\test\\file.txt", std::ios::in | std::ios::binary);
if(NULL != in)
{ cout<<"File Open Success"<<endl;
in.seekg(0, std::ios::end);
DataVal.resize(in.tellg());
in.seekg(0, std::ios::beg);
in.read(&DataVal[0], DataVal.size());
in.close();
}
else { cout<<"File Open Failure"<<endl;
return 0;
}
Here I am able to copy the entire file content into the "DataVal". That is fine.
Instead I want to copy the text data into DataVal.at(i++); whenever it hits the new line.Thanks well in advance.
Praveen*