Data Conversion - aaaargh!
I have a value (long FPS) that I need to pass to a PrintToScreen function that accepts char * (PrintToScreen(char *)). Unfortunately, I''m rubbish at converting data values and the VC++ help files are hard to navigate if you don''t know exactly what you are looking for.
I tried passing (char*)&FPS but the result was gibberish. I suspect this is because I am converting the type but not the actual data stored in memory. For instance, if FPS is 30, I need the char value to be "30".
I know the answer will probably be simplistic but I would appreciate any help.
Cheers,
pan narrans
Minister of Propaganda : leighstringer.com : Nobody likes the man who brings bad news - Sophocles (496 BC - 406 BC), Antigone
You need to convert your long into a string (array of characters).
This can be done using sprintf or itoa, which you should be able to type in, highlight, and press F1 to get help on.
Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
This can be done using sprintf or itoa, which you should be able to type in, highlight, and press F1 to get help on.
Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
I knew it would be simple:
char buffer[3];
_itoa( FPS, buffer, 10 );
PrintToScreen( buffer );
Just posted the solution in case anyone ever searches for it
Thanx siaspete
char buffer[3];
_itoa( FPS, buffer, 10 );
PrintToScreen( buffer );
Just posted the solution in case anyone ever searches for it
Thanx siaspete
Minister of Propaganda : leighstringer.com : Nobody likes the man who brings bad news - Sophocles (496 BC - 406 BC), Antigone
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement