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. Can I declare a path with a single "\"

Can I declare a path with a single "\"

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharphelpquestion
4 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.
  • N Offline
    N Offline
    nigma_x
    wrote on last edited by
    #1

    I'm using Visual C++.net 2002 With MFC. I know I can declare a path "C:\\folder\\file.txt but is there a way to declare it "C:\folder\file.txt". If so how? Thanks for any help.

    D V 2 Replies Last reply
    0
    • N nigma_x

      I'm using Visual C++.net 2002 With MFC. I know I can declare a path "C:\\folder\\file.txt but is there a way to declare it "C:\folder\file.txt". If so how? Thanks for any help.

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      For string literals, backslashes must be doubled. Why is this a problem?


      "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

      M 1 Reply Last reply
      0
      • N nigma_x

        I'm using Visual C++.net 2002 With MFC. I know I can declare a path "C:\\folder\\file.txt but is there a way to declare it "C:\folder\file.txt". If so how? Thanks for any help.

        V Offline
        V Offline
        V 0
        wrote on last edited by
        #3

        In C# you can in C++ you can't. For C# use the @ like this: @"C:\folder\file.txt" the "\\" is still valid in C# (without the '@'); "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix

        1 Reply Last reply
        0
        • D David Crow

          For string literals, backslashes must be doubled. Why is this a problem?


          "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

          M Offline
          M Offline
          Mika Larramo
          wrote on last edited by
          #4

          Sometimes it can create very strange bugs if you forget one double backslash in a path... I have never liked this, but I have learned to live with it...

          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