Archived

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

Problem with sprintf and optimization?

This topic is 6357 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, got a little problem here... using sprintf as so: sprintf (lpVar,"%d",3); okay- here is the problem.... if compile with Visual Studio 6.0 under Win2000 -Optimize for maximum speed The resultant program goes into a 100% cpu loop and never returns -Optimize for default the resultant program seems to function okay. any Ideas? (got servicepack 3; gonna dl 4 tonight)

Share this post


Link to post
Share on other sites
Well... the problem is probably somewhere else.. Did you actually allocate memory for lpVar? And is it indeed a character pointer?

Share this post


Link to post
Share on other sites
okay, so here is what I did:

restored my source files to the original configuration-
(back''d up to CD-R)

recoded the changes I had made since last backup (not to many so no problem)

now it works?@!?@?@!?@???

I must have made a little mistake and not noticed? Weird....


In addition, when I ran WinDiff before I restored, the files that were different "looked" okay (code wise)....

can a workspace corrupt?

Jason

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
In Windows, just about everything can corrupt.

Share this post


Link to post
Share on other sites
Wrenhal''s right. If you ever get a "works in release but not in debug" or "works in optimization but not with no-opt", your bug is insidious--either a wild pointer or (if multithreading) a race condition between threads. The key is
1) prevention: don''t leave yourself the opportunity to make mistakes. adopt good (& SAFE) programming styles.
2) debug skills: when "it" breaks, you need to have the ability to figure out exactly what broke. This is one of the most essential software development skills that nobody really "teaches" in a classroom.

Share this post


Link to post
Share on other sites