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 "new line" in Cstring?

how to "new line" in Cstring?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
9 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.
  • S Offline
    S Offline
    Smith
    wrote on last edited by
    #1

    just like \n for char[].. i want to display like "test string line1 \n test string2 line2 \n test string3 line3 \n" in CEdit. CString cs; cs="test string line1 \n"; cs +="test string line2\n"; cs +="test string line3\n"; m_Contrl.SetWindowText(cs); it didn't work :( regards, Rookie

    S T A D 4 Replies Last reply
    0
    • S Smith

      just like \n for char[].. i want to display like "test string line1 \n test string2 line2 \n test string3 line3 \n" in CEdit. CString cs; cs="test string line1 \n"; cs +="test string line2\n"; cs +="test string line3\n"; m_Contrl.SetWindowText(cs); it didn't work :( regards, Rookie

      S Offline
      S Offline
      Smith
      wrote on last edited by
      #2

      just like we have VbCrlf in vb. regards, Rookie

      1 Reply Last reply
      0
      • S Smith

        just like \n for char[].. i want to display like "test string line1 \n test string2 line2 \n test string3 line3 \n" in CEdit. CString cs; cs="test string line1 \n"; cs +="test string line2\n"; cs +="test string line3\n"; m_Contrl.SetWindowText(cs); it didn't work :( regards, Rookie

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

        is your control set to multiline ??


        TOXCCT >>> GEII power
        [toxcct][VisualCalc]

        S 1 Reply Last reply
        0
        • T toxcct

          is your control set to multiline ??


          TOXCCT >>> GEII power
          [toxcct][VisualCalc]

          S Offline
          S Offline
          Smith
          wrote on last edited by
          #4

          ya.. it is set to multiline.. still its not working.. do u think "\n" will work in CString?? regards, Rookie

          S 1 Reply Last reply
          0
          • S Smith

            ya.. it is set to multiline.. still its not working.. do u think "\n" will work in CString?? regards, Rookie

            S Offline
            S Offline
            Smith
            wrote on last edited by
            #5

            even i tried like this char c[20]; strcpy(c,"line 1\n"); strcat(c,"line2\n"); CString cs; cs = c; m_Control.setWindowText(cs); its displaying like "line1|line2"; please help. thanks, Rookie

            1 Reply Last reply
            0
            • S Smith

              just like \n for char[].. i want to display like "test string line1 \n test string2 line2 \n test string3 line3 \n" in CEdit. CString cs; cs="test string line1 \n"; cs +="test string line2\n"; cs +="test string line3\n"; m_Contrl.SetWindowText(cs); it didn't work :( regards, Rookie

              A Offline
              A Offline
              AndyCheetham
              wrote on last edited by
              #6

              Try CString cs; cs="test string line1 \r\n"; cs +="test string line2\r\n"; cs +="test string line3\r\n"; ... AndyC

              S 1 Reply Last reply
              0
              • A AndyCheetham

                Try CString cs; cs="test string line1 \r\n"; cs +="test string line2\r\n"; cs +="test string line3\r\n"; ... AndyC

                S Offline
                S Offline
                Smith
                wrote on last edited by
                #7

                Andy \r\n is working .... :-D its workingggg...:-O thanx thanx thanx thanx... regards, Rookie

                T 1 Reply Last reply
                0
                • S Smith

                  Andy \r\n is working .... :-D its workingggg...:-O thanx thanx thanx thanx... regards, Rookie

                  T Offline
                  T Offline
                  toxcct
                  wrote on last edited by
                  #8

                  yes it does, but be careful, it is windows specific !! ;)


                  TOXCCT >>> GEII power
                  [toxcct][VisualCalc]

                  1 Reply Last reply
                  0
                  • S Smith

                    just like \n for char[].. i want to display like "test string line1 \n test string2 line2 \n test string3 line3 \n" in CEdit. CString cs; cs="test string line1 \n"; cs +="test string line2\n"; cs +="test string line3\n"; m_Contrl.SetWindowText(cs); it didn't work :( regards, Rookie

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

                    A carriage return is \r. A line feed is \n. A CRLF pair is \r\n. This has nothing to do with CString.


                    "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

                    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