I need your help... Again...
How can i combine reading from file with std::getline(file, std::string); and UpdateData(FALSE); ? UpdateData() accepts only CString and getline only std::string, and then i try to use it like that:

std::string readbuff;
int length;
std::ifstream file("file.txt");
while(getline(file, str))
{
	length = str.length();
	for(int i=0; i<length; i++)
		CStr[i] = str[i]; //CStr is global CString variable used at DoDataExchange;
	UpdateData(FALSE);
	Sleep(5000);
}

i recieve following error:
error C2106: '=' : left operand must be l-value
I know fstream has something like file.read(); but then calling this function i have to give a number of symbols that i want to read. Am i right? And i don't know how to do that. So what can i do?

And also how can i read only one line, for example just 6th line?

did you declare variable CStr? CString Cstr; Instead of that loop, just try this: CSt = str.c_str(); assuming CStr is of type CString.

did you declare variable CStr? CString Cstr; Instead of that loop, just try this: CSt = str.c_str(); assuming CStr is of type CString.

Thank you. That worked :) And what about reading only one line wich is not first line in the file?

Standard i/o stuff -- read the file from beginning to end until you find the line you want. This is a first year programming question, are you sure you are ready to write MFC programs?

I know how to read line by line till i'll find required line. But i was wondering if there is special function for that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.