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. equivalent of c# @"" string literal?

equivalent of c# @"" string literal?

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++question
8 Posts 5 Posters 1 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
    Jon Hulatt
    wrote on last edited by
    #1

    In C# you can tell the compiler not to expand escape sequences in string literals by prefixing the string with an @ symbol:-

    string test = @"C:\test.jpg";

    Is there an equivalent notation to do the same in VC++ ? (2008) thanks Jon

    using System.Beer;

    T _ C 3 Replies Last reply
    0
    • J Jon Hulatt

      In C# you can tell the compiler not to expand escape sequences in string literals by prefixing the string with an @ symbol:-

      string test = @"C:\test.jpg";

      Is there an equivalent notation to do the same in VC++ ? (2008) thanks Jon

      using System.Beer;

      T Offline
      T Offline
      Taran9
      wrote on last edited by
      #2

      use double backslash like "C:\\test.jpg"

      1 Reply Last reply
      0
      • J Jon Hulatt

        In C# you can tell the compiler not to expand escape sequences in string literals by prefixing the string with an @ symbol:-

        string test = @"C:\test.jpg";

        Is there an equivalent notation to do the same in VC++ ? (2008) thanks Jon

        using System.Beer;

        _ Offline
        _ Offline
        _Superman_
        wrote on last edited by
        #3

        You can do it the hard way. :)

        char test[] = { 'C', ':', 92, 't', 'e', 's', 't', '.', 'j', 'p', 'g', 0 };

        «_Superman_» I love work. It gives me something to do between weekends.

        1 Reply Last reply
        0
        • J Jon Hulatt

          In C# you can tell the compiler not to expand escape sequences in string literals by prefixing the string with an @ symbol:-

          string test = @"C:\test.jpg";

          Is there an equivalent notation to do the same in VC++ ? (2008) thanks Jon

          using System.Beer;

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          Nope (in fact the '@ improvement' is the main reason to leave C++ in favour of C# :rolleyes: ). :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          J B 2 Replies Last reply
          0
          • C CPallini

            Nope (in fact the '@ improvement' is the main reason to leave C++ in favour of C# :rolleyes: ). :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            J Offline
            J Offline
            Jon Hulatt
            wrote on last edited by
            #5

            The [i]main[/i] reason? I can think of several more...

            using System.Beer;

            C 1 Reply Last reply
            0
            • J Jon Hulatt

              The [i]main[/i] reason? I can think of several more...

              using System.Beer;

              C Offline
              C Offline
              CPallini
              wrote on last edited by
              #6

              Well, you're right: you may also safely miss the semicolon at the end of a class declaration... :-D

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              1 Reply Last reply
              0
              • C CPallini

                Nope (in fact the '@ improvement' is the main reason to leave C++ in favour of C# :rolleyes: ). :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                B Offline
                B Offline
                BadKarma
                wrote on last edited by
                #7

                Blasphemy :mad:

                Learn from the mistakes of others, you may not live long enough to make them all yourself.

                C 1 Reply Last reply
                0
                • B BadKarma

                  Blasphemy :mad:

                  Learn from the mistakes of others, you may not live long enough to make them all yourself.

                  C Offline
                  C Offline
                  CPallini
                  wrote on last edited by
                  #8

                  In bad mood, today? :-D

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                  [My articles]

                  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