Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. std::string error after append

std::string error after append

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    justin223
    wrote on last edited by
    #1

    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

    R 1 Reply Last reply
    0
    • J justin223

      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

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      Verifier wrote: strInsert += "strInsert += szName; HUmm .. is that really what you wrote in your code ? ~RaGE();

      J 1 Reply Last reply
      0
      • R Rage

        Verifier wrote: strInsert += "strInsert += szName; HUmm .. is that really what you wrote in your code ? ~RaGE();

        J Offline
        J Offline
        justin223
        wrote on last edited by
        #3

        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</

        J M 2 Replies Last reply
        0
        • J justin223

          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</

          J Offline
          J Offline
          jhwurmbach
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • J justin223

            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</

            M Offline
            M Offline
            Mike Nordell
            wrote on last edited by
            #5

            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.

            J 1 Reply Last reply
            0
            • M Mike Nordell

              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.

              J Offline
              J Offline
              justin223
              wrote on last edited by
              #6

              Mike Nordell wrote: 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)? yep. I printed out the text and it was correct. thanks! :laugh:

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups