Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MessageBox gives exception 1

Status
Not open for further replies.

HyperEngineer

Programmer
May 8, 2002
190
US
I am using VC++ 2008. I am using MessageBox to give error info to the user. The code compiles fine. But when I run the program it will crash when it tries to display the MessageBox. (I tried MessageBox("This is an error"); MessageBox(_T("This is an error")); AfxMessageBox("This is an error"); and AfxMessageBox(_T("This is an error"));) The exception is:

Unhandled exception at 0x7c80a5a2 in myapp.exe: 0xC0000005: Access violation reading location 0xfefefefe.

thanks,

HyperEngineer
If it ain't broke, it probably needs improvement.
 
Thanks Salem. That's what I was doing. In another class that was called from the main class, I was doing strange things with strtok_s(). And the program didn't like it.

Code:
buff = GetCommandLine();

token = strtok_s(buff, &seps1, &next_token);
sprintf_s(buff, 128, "%s", next_token);
token = strtok_s(buff, &seps2, &next_token);

Something was happening to the memory with this. Now the code is

Code:
buff = GetCommandLine();

token = strtok_s(buff, &seps1, &next_token);
token = strtok_s(NULL, &seps2, &next_token);

Don't know why I thought I had to readjust the input into strtok_s() because I was changing the seperator.

Everything is OK now. Why it affected the MessageBox functions is still a mystery.

thanks,

HyperEngineer
If it ain't broke, it probably needs improvement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top