std::string error after append
-
strInsert is a std::string, szName is const char* and strValue is a std::string. strInsert = "<"; strInsert += szName; strInsert += ">"; strInsert += strValue; strInsert += "\r\n"; Can anyone tell me if the above commented line fucks up the string? The string looks like this before the commented line: yahyah
-
strInsert is a std::string, szName is const char* and strValue is a std::string. strInsert = "<"; strInsert += szName; strInsert += ">"; strInsert += strValue; strInsert += "\r\n"; Can anyone tell me if the above commented line fucks up the string? The string looks like this before the commented line: yahyah
-
Verifier wrote: strInsert += "strInsert += szName; HUmm .. is that really what you wrote in your code ? ~RaGE();
nope. this is what i wrote: strInsert = "<"; strInsert += szName; strInsert += ">"; strInsert += strValue; strInsert += "</"; strInsert += szName; //this line fucksup the whole string strInsert += ">\r\n"; Can anyone tell me if the above commented line fucks up the string? The string looks like this before the commented line: <hejsan>yah</ And after it: 8Hsan>yah</
-
nope. this is what i wrote: strInsert = "<"; strInsert += szName; strInsert += ">"; strInsert += strValue; strInsert += "</"; strInsert += szName; //this line fucksup the whole string strInsert += ">\r\n"; Can anyone tell me if the above commented line fucks up the string? The string looks like this before the commented line: <hejsan>yah</ And after it: 8Hsan>yah</
You could try
std::string strName(szName);
before your code snippet, and then only append strName. But honestly, I have no idea what is happening to your string. You really should be able to use it this way.
My opinions may have changed, but not the fact that I am right.
-
nope. this is what i wrote: strInsert = "<"; strInsert += szName; strInsert += ">"; strInsert += strValue; strInsert += "</"; strInsert += szName; //this line fucksup the whole string strInsert += ">\r\n"; Can anyone tell me if the above commented line fucks up the string? The string looks like this before the commented line: <hejsan>yah</ And after it: 8Hsan>yah</
Verifier wrote: Can anyone tell me if the above commented line f***s up the string? From what you displayed; yes it does. :-) Let me guess, you're using VC7 and got those results from watching the string in the debugger, not from really outputing it to the console (or something similar)? :-) Check the implementation of basic_string and you'll see what causes this (you might also want to search some MS NG's and see you're far from alone in having been bitten by this). An MS dude wrote some code (a debugger extension) to handle this. Should be available from the public.vc.lang NG archives.
-
Verifier wrote: Can anyone tell me if the above commented line f***s up the string? From what you displayed; yes it does. :-) Let me guess, you're using VC7 and got those results from watching the string in the debugger, not from really outputing it to the console (or something similar)? :-) Check the implementation of basic_string and you'll see what causes this (you might also want to search some MS NG's and see you're far from alone in having been bitten by this). An MS dude wrote some code (a debugger extension) to handle this. Should be available from the public.vc.lang NG archives.