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. String Problems

String Problems

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
5 Posts 3 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.
  • T Offline
    T Offline
    TheCult
    wrote on last edited by
    #1

    Hi i have one CString which has text in it, i wish to scan thsi text and replace all the "\" with another charature. However every time i try to search the string looking for the "\" using strchr etc all i get is an error message saying error C2001: newline in constant any help on how to slove this?

    I 1 Reply Last reply
    0
    • T TheCult

      Hi i have one CString which has text in it, i wish to scan thsi text and replace all the "\" with another charature. However every time i try to search the string looking for the "\" using strchr etc all i get is an error message saying error C2001: newline in constant any help on how to slove this?

      I Offline
      I Offline
      includeh10
      wrote on last edited by
      #2

      it is "\"", not "\" use strchr(p, '\"') is better or CString.Replace() function do you mean "\\" or '\\'?

      T 1 Reply Last reply
      0
      • I includeh10

        it is "\"", not "\" use strchr(p, '\"') is better or CString.Replace() function do you mean "\\" or '\\'?

        T Offline
        T Offline
        TheCult
        wrote on last edited by
        #3

        i'vew tried both Replace() and strchr and they dont find the \ in the string, i tried str.Replace('\"', 'A') and it did nothing, if i change the '/"' to another letter in the string it replaces them perfectly. any idea whats up? thanks

        I K 2 Replies Last reply
        0
        • T TheCult

          i'vew tried both Replace() and strchr and they dont find the \ in the string, i tried str.Replace('\"', 'A') and it did nothing, if i change the '/"' to another letter in the string it replaces them perfectly. any idea whats up? thanks

          I Offline
          I Offline
          includeh10
          wrote on last edited by
          #4

          the \ is '\\' in code. includeh10

          1 Reply Last reply
          0
          • T TheCult

            i'vew tried both Replace() and strchr and they dont find the \ in the string, i tried str.Replace('\"', 'A') and it did nothing, if i change the '/"' to another letter in the string it replaces them perfectly. any idea whats up? thanks

            K Offline
            K Offline
            Konrad Windszus
            wrote on last edited by
            #5

            Because "\" is an escape character prefix you have to write "\\" if you mean the "\". You can also escape other characters with the single \, e.g. \n \r \" Regards Konrad

            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