• Advertisement

Archived

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

Assertion in stringstream?

This topic is 5979 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

I''ve started getting debug assertions on my fps display code which uses a stringstream to combine my text and numbers. I poked around and found that the assertion seems to appear on this line : std::stringstream temp; Not much to go wrong is there... I''m not out of memory... Can anyone think of why this would occur, about every 30 seconds that the application runs(this part of the code runs only once per second). Oh, I''m using VC7(.net). Is there a better way of putting my int in a string? Many thanks

Share this post


Link to post
Share on other sites
Advertisement
I know of a simple way to put an int into a string but I don't know what's causing you that error. Here goes

char string[80];
int number=4;

sprintf(string,"I've put the number %d, into my string",number);

this show make the string: string read as:

I've put the number 4, into my string

this function sprintf is part of the C library and the header file for this u should include is

string.h


I hope I helped


Dark Star
UK





Edited by - Dark Star on September 5, 2001 11:27:57 AM

Share this post


Link to post
Share on other sites
Sometimes (at least with MSVC 6.0), the assertion is actually on the line before where the green arrow appears in the debugger.

Does this function only crash after a certain time? It sounds from your post like this line is being run successfully a number of times, and then crashes later. If that''s the case, you may have a wild pointer or something. I''d set a breakpoint and step through--you should be able to see exactly what the assertion is since STL source is available.

I haven''t seen that kind of behavior from stringstream before.

Share this post


Link to post
Share on other sites

  • Advertisement