Archived

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

strlwr under VC++

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

Return Value
Returns a pointer to the altered string. Because the modification is done in place, the pointer returned is the same as the pointer passed as the input argument. No return value is reserved to indicate an error.


// this will crash
char *pString = "My String";
strupr(pString);


// this will crash too
strupr("My String");

// this will not crash
char pString[256] = "My String";
strupr(pString);

Share this post


Link to post
Share on other sites
I dont care what anyone says. this is an error on microsoft''s part. If its compiled as a Release it doesnt crash, however under Debug it does. This is not right. They should behave identically; It should either always crash or always not crash. The debug code should NOT alter the running of the program. The only reason its there is to allow the debugger to locate the error in the context of the original C++ source.

I probably should stop, My doctor says I have the wrists of an 80-year old

Share this post


Link to post
Share on other sites
quote:
The debug code should NOT alter the running of the program. The only reason its there is to allow the debugger to locate the error in the context of the original C++ source.

I think you will find a massive opposition to that statement. I need only say the word "assert" to prove you wrong.

Share this post


Link to post
Share on other sites
quote:
Original post by Nodger
I dont care what anyone says. this is an error on microsoft''s part. If its compiled as a Release it doesnt crash, however under Debug it does. This is not right.

Actually, this is perfectly right. The Debug runtime is set up so that bugs cause a crash as much as possible. It initializes memory to bogus values, checks pointers, and does rigorous checks of the memory allocator''s internal state. Why? Because it''s much better to catch these bugs during development, than it is to not realize them, and ship a product with undiscovered bugs to cause problems.

The fact remains that the problem is with something **you** are doing in your code. Go through it with the debugger and make sure you''re passing a valid, writeable array to the strlwr function.

Also, a quick tip: Posting "There''s such-and-such a bug in Visual C++" or "This is all Microsoft''s fault" is basically the same as waving a huge blinking neon sign above your head that says "I''M A TOTAL NEWBIE, AND WHINY TOO". If there''s a bug, someone''s already found it. If they''ve already found it, there''s plenty of information on the ''net about it already. So do a google search, and if nothing turns up from reputable sources, assume it''s something you''re doing wrong.


"Sneftel is correct, if rather vulgar." --Flarelocke

Share this post


Link to post
Share on other sites