Thread: C++ Code Error?
View Single Post
  #5   Spotlight this post!  
Unread 19-01-2003, 14:47
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
You still need to allocate memory, however. Just because you "lock" the memory doesn't mean that it exists.

As for your message box thing: you've got to allocate some memory for the pointer. You've got two options here:
1. change display from a char * to a char[32]. (or some other sub-script)
2. allocate some memory via new. Ie. display=new char[32]. If you do this, don't forget to delete it once you're done with it.

If you don't do this, all you've got is a pointer to, usually, 0xcdcdcdcd (or something like that), which isn't valid. When itoa tries to copy text to this location, it's going to crash because there is no memory there to copy it to.

--Rob
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php