Tuesday, 15 September 2015

C++ Winapi. Read first line from a file, displaying in a textbox -



C++ Winapi. Read first line from a file, displaying in a textbox -

i have begun experiment winapi in c++. coming along nicely far.

i having problem finding way read first line of file, , displaying in textbox.

after google searching seems people suggest using winapis functions this, while other using fstream simpler. did go fstream way run in trouble, nil hard but, cannot find reply it!

this code:

string line; ifstream filen ("tid.txt"); if (filen.is_open()) { getline (filen,line); cout << line << endl; filen.close(); } setdlgitemtext(hwnd, idc_main_edit, line);

this give me problem compiler:

cannot convert `std::string' `const char*'

need somekind of conversion here, dont know what.

what think?

try this:

setdlgitemtext(hwnd, idc_main_edit, line.c_str());

c++ winapi fstream

No comments:

Post a Comment