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. how to define a const multileline string

how to define a const multileline string

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
8 Posts 5 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.
  • X Offline
    X Offline
    xiaohe521
    wrote on last edited by
    #1

    how to define a const multileline string as const string TEMPLATE = "HELLO! IF YOU CAN HELP ME , I WILL THANK YOU VERY MUCH"; this can not pass complie I love Programming

    F X J 3 Replies Last reply
    0
    • X xiaohe521

      how to define a const multileline string as const string TEMPLATE = "HELLO! IF YOU CAN HELP ME , I WILL THANK YOU VERY MUCH"; this can not pass complie I love Programming

      F Offline
      F Offline
      followait
      wrote on last edited by
      #2

      const string TEMPLATE = "HELLO!\nIF YOU CAN HELP ME ,\nI WILL THANK YOU VERY MUCH";

      X 1 Reply Last reply
      0
      • F followait

        const string TEMPLATE = "HELLO!\nIF YOU CAN HELP ME ,\nI WILL THANK YOU VERY MUCH";

        X Offline
        X Offline
        xiaohe521
        wrote on last edited by
        #3

        sorry , i don't want the "\n", because it not readable if there is a solution that present multile line is very good! I love Programming

        C 1 Reply Last reply
        0
        • X xiaohe521

          sorry , i don't want the "\n", because it not readable if there is a solution that present multile line is very good! I love Programming

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          I'm afraid you are not in a position to write the language yourself, you have to live with the language as it exists. Best you can do is this: #define NEWLINE \r\n and then use NEWLINE, or something similar. In any case, \n won't work, it's \r\n ( or \n\r, I forget ). Christian Graus - Microsoft MVP - C++

          L 1 Reply Last reply
          0
          • X xiaohe521

            how to define a const multileline string as const string TEMPLATE = "HELLO! IF YOU CAN HELP ME , I WILL THANK YOU VERY MUCH"; this can not pass complie I love Programming

            X Offline
            X Offline
            xiaohe521
            wrote on last edited by
            #5

            the solution as: const string TEMPLATE = "HELLO! \n\ IF YOU CAN HELP ME ,\n\ I WILL THANK YOU VERY MUCH!"; I love Programming

            1 Reply Last reply
            0
            • X xiaohe521

              how to define a const multileline string as const string TEMPLATE = "HELLO! IF YOU CAN HELP ME , I WILL THANK YOU VERY MUCH"; this can not pass complie I love Programming

              J Offline
              J Offline
              Jose Lamas Rios
              wrote on last edited by
              #6

              Do you want it to be multiline only in your source code

              const string TEMPLATE = "These three string literals will be "
                "concatenated and the result assigned "
                "to TEMPLATE as a single string";

              or do you want it to contain multiple lines

              const string TEMPLATE = "These are the first,\r\nsecond,\r\nand third lines";

              or both?

              const string TEMPLATE = "These are the first,\r\n"
                "second,\r\n"
                "and third lines";

              -- jlr http://jlamas.blogspot.com/[^]

              X 1 Reply Last reply
              0
              • J Jose Lamas Rios

                Do you want it to be multiline only in your source code

                const string TEMPLATE = "These three string literals will be "
                  "concatenated and the result assigned "
                  "to TEMPLATE as a single string";

                or do you want it to contain multiple lines

                const string TEMPLATE = "These are the first,\r\nsecond,\r\nand third lines";

                or both?

                const string TEMPLATE = "These are the first,\r\n"
                  "second,\r\n"
                  "and third lines";

                -- jlr http://jlamas.blogspot.com/[^]

                X Offline
                X Offline
                xiaohe521
                wrote on last edited by
                #7

                very good! what i need is the third solution , both the source code in multiline and the output! thank you! thanks all! I love Programming

                1 Reply Last reply
                0
                • C Christian Graus

                  I'm afraid you are not in a position to write the language yourself, you have to live with the language as it exists. Best you can do is this: #define NEWLINE \r\n and then use NEWLINE, or something similar. In any case, \n won't work, it's \r\n ( or \n\r, I forget ). Christian Graus - Microsoft MVP - C++

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  \r\n for Windows, \n for Unix and \r for Mac. I love standards :sigh: The tigress is here :-D

                  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