std::string::size or length ARRRGGGH

Started by
7 comments, last by billybob 21 years, 1 month ago
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]
Advertisement
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
err k, its a matter of taste.

it crashes in strlen.asm, so its not the printf.
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.
What compiler and STL implementation are you using? The code, as you''ve posted it, looks fine.
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.

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.
Make sure you have all the MSVC STL fixes (see my signature) before proceeding, or download STLPort. You might even have a corrupt install somewhere.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]
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]

This topic is closed to new replies.

Advertisement