• Advertisement

Archived

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

NeoEngine and sprintf call

This topic is 4971 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys... I am using the neoengine and try to sabe the axis angle, to an exporting script...
char * info;
AxisAngle rotation = pkBox->getRotation().ToAxisAngle();
sprintf(info, "%20.4f", rotation.m_pkAngle.x);
 
but when the sprintf call is enabled in the code(and compiler returns no errors at all!) there is a point that engine just halt and doesnt start. Can help me? The third parameter is a float guy. I just want to convert the float to string. Thank you!

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by guivieira


sprintf(info, "%20.4f", rotation.m_pkAngle.x);






Do you need the extra ''2'' in "%20.4f" -> shouldn''t it be "%.4f" ?

Share this post


Link to post
Share on other sites
what about allocating some memory for your char-array?

you are just overwriting memory with this method.

char info[26]; // 20 + '.' + 4 + '\0'
or
char *info = new char[26]; // 20 + '.' + 4 + '\0'
(don't forget to delete this when you don't need it anymore)

good luck
Charon

[edited by - Charon on June 9, 2004 10:04:09 AM]

Share this post


Link to post
Share on other sites
quote:
it WORKS!!!!!!!!!!
mmmmmmAHUAHUHEUAHUEHAUHEUAEHAE


like a:

delete info;


?!?!?



If you allocated it with new,

delete [] info;

[edited by - fartocci on June 9, 2004 11:27:28 PM]

Share this post


Link to post
Share on other sites

  • Advertisement