char scTemp[8];
unsigned short usCurrent;
m_ctEdTemp.GetWindowText(scTemp, 8);
sscanf(scTemp, "%u", usCurrent);
Does anyone know what is wrong with this code (I'm sure it's a very basic mistake) ?
Well, the first thing you did wrong is you ignored using Code tags around code snippets.
The second one is parameters passed in CWnd::GetWindowText: you must specify the nMaxCount value to be less than the size of your char scTemp[8] array (because one character in it must be the terminated NULL one).
And finally, you should forget about plain char arrays and sscanf C-runtime function in MFC applications. Use CString class!
Bookmarks