Archived

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

std::string::size or length ARRRGGGH

This topic is 5420 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'm getting a crash in std::string::size or std::string::length NO MATTER WHAT I DO. every single freaking time crash and asks for strlen.asm. THIS crashes:
int main(int argc, char ** argv)
{
 std::string test("lala");
 printf("%d", test.length());
 return 0;
}
  
so is it just a worthless piece of crap (sure seems like it) or what am i doing wrong. [edited by - billybob on March 17, 2003 3:51:18 AM]

Share this post


Link to post
Share on other sites
well if youre gonna use strings you shouldnt use printf one is C++ one is C
I would use std::cout << test.length() << std::endl; that could be your prob

Share this post


Link to post
Share on other sites
err k, its a matter of taste.

it crashes in strlen.asm, so its not the printf.

Share this post


Link to post
Share on other sites
hmmmmmm. Tricky problem. Step down through the stack trace into the frame that calls strlen, and find out whether the arguments it''s passing in are valid.


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
What compiler and STL implementation are you using? The code, as you''ve posted it, looks fine.

Share this post


Link to post
Share on other sites
msvc++ 6, don''t know what STL version it is. i know it should be fine but no matter what i do it never works. i''ve tried strlen("lala") and it works perfectly, so i have no idea why this doesn''t work.

Share this post


Link to post
Share on other sites
Downloading STLPort would be a avoiding rather than solving the problem, but it might be your easiest way out.

Have you done any messing around with library linking? (Debug versus Release, Single-Threaded versus Multithreaded)


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
bah it worked, i wasted SOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO MUCH TIME on that.

edit: STL port did.

[edited by - billybob on March 17, 2003 7:21:27 AM]

Share this post


Link to post
Share on other sites