CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    TCHAR '\' use, adds space

    When Im using the following code

    Code:
    CString cstrTemp = _T("Sample text goes here Line 1\
           Sample text goes here Line 2\
          Sample text goes here Line 3\");
    
    AfxMessageBox (cstrTemp);
    this code adds tabs to my text on messagebox. used '\' for next line code.
    ◄◄ hypheni ►►

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: TCHAR '\' use, adds space

    Quote Originally Posted by hypheni View Post
    When Im using the following code

    Code:
    CString cstrTemp = _T("Sample text goes here Line 1\
           Sample text goes here Line 2\
          Sample text goes here Line 3\");
    
    AfxMessageBox (cstrTemp);
    this code adds tabs to my text on messagebox. used '\' for next line code.
    Code:
    3\"
    What does that do?

    Also, didn't the compiler warn you of an invalid escape sequence on that line?

    Regards,

    Paul McKenzie

  3. #3
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: TCHAR '\' use, adds space

    Are you trying to get three lines in your edit control or just continue your code on the next line?

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: TCHAR '\' use, adds space

    used '\' for next line code.
    This instructs to escape the LF symbol at the end of the line, but leading tab symbol on the next line is still there. That one you have in the message box.

    In fact the three lines should be glued like this:
    Code:
    CString cstrTemp = _T("Sample text goes here Line 1\n")
          _T("Sample text goes here Line 2\n")
          _T("Sample text goes here Line 3");
    Best regards,
    Igor

  5. #5
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: TCHAR '\' use, adds space

    Yes Im trying to continue my code next line.


    Igor your method worked.
    ◄◄ hypheni ►►

  6. #6
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: TCHAR '\' use, adds space

    Quote Originally Posted by hypheni View Post
    Yes Im trying to continue my code next line.
    and, if the next line has tabs, then logically, the resulted string will contain tabs.
    Igor your method worked.
    Of course, that way you have to write.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured