Archived

This topic is now archived and is closed to further replies.

HappyToLearnC

Casting

Recommended Posts

I want to view a "long" in the MessageBox Here is a simple version of what I am doing : long xyz = 4; char* ok; ok = (char*)xyz; MessageBox(NULL,ok,"",MB_OK); When I execute I get the system error saying : The instruction at 0x77e13e49......ref memory could not be read" Could someone help? My best regards

Share this post


Link to post
Share on other sites
looks like you''re trying to dereference a null pointer...
this right here is your problem:

long xyz = 4;
char* ok;
ok = (char*)xyz;

you cant'' "cast" a long to a character array. you''ll have to
convert it using a manual algorithm (or one that''s already availible).
i know there''s an atoi() and itoa() function, perhaps there is an
ltoa() function as well, i''m too lazy to look it up

anyway, that''s where the problem is at, im sure you can take it
from here.

-eldee
;another space monkey;
[ Forced Evolution Studios ]


::evolve::

''In C we had to code our own bugs. In C++ we can inherit them.''

Share this post


Link to post
Share on other sites