Click here to Skip to main content
15,916,941 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to execute tab and newline? Pin
Cedric Moonen22-Jul-10 4:32
Cedric Moonen22-Jul-10 4:32 
GeneralRe: How to execute tab and newline? Pin
Joseph8222-Jul-10 4:53
Joseph8222-Jul-10 4:53 
GeneralRe: How to execute tab and newline? Pin
Cedric Moonen22-Jul-10 4:57
Cedric Moonen22-Jul-10 4:57 
QuestionRe: How to execute tab and newline? Pin
Maximilien22-Jul-10 4:49
Maximilien22-Jul-10 4:49 
AnswerRe: How to execute tab and newline? Pin
Joseph8222-Jul-10 4:54
Joseph8222-Jul-10 4:54 
GeneralRe: How to execute tab and newline? Pin
Maximilien22-Jul-10 4:57
Maximilien22-Jul-10 4:57 
GeneralRe: How to execute tab and newline? Pin
Joseph8222-Jul-10 6:46
Joseph8222-Jul-10 6:46 
GeneralRe: How to execute tab and newline? Pin
Sauro Viti22-Jul-10 7:21
professionalSauro Viti22-Jul-10 7:21 
It make no sense to "execute" a newline inside a string! Inside a string you could put printable characters, like 'a', 'b', 'c' and so on, and/or control characters, like '\t' (i.e. TAB), '\n' (i.e. LF) and so on.
If you pass such a string to functions like printf, that functions will print-out the printable characters and do what the control characters ask for, for example:

C++
printf("first>\tthis is a sentence...\nsecond>\tthis is another sentence...")


will produce an output on screen similar to the following:

C++
first>  this is a sentence...
second> this is another sentence...


as you can see TAB (\t) is not simply expanded to a certain number of characters, but it make the text formatted in columns; the LF instead instruct the printf function to move to the beginning of the next line and place the remaining text there.

Then:


  1. if you like it, you can replace the TABs expanding them to a fixed number of spaces (supposed that you have a CString named str, you have only to call str.Replace(_T("\t"), _T(" ")); on it); be aware that usually this is not the behaviour of TAB that the rest of the world is expecting.
  2. absolutely it make no sense to replace the \n characters in a string with newline because in strings \n has the meaning of newline!

GeneralRe: How to execute tab and newline? Pin
Joseph8222-Jul-10 9:49
Joseph8222-Jul-10 9:49 
QuestionDesingning a Dialog Box's and forms Pin
rrthangavel22-Jul-10 3:58
rrthangavel22-Jul-10 3:58 
AnswerRe: Desingning a Dialog Box's and forms Pin
Maximilien22-Jul-10 5:15
Maximilien22-Jul-10 5:15 
AnswerRe: Desingning a Dialog Box's and forms Pin
rp_suman22-Jul-10 5:57
rp_suman22-Jul-10 5:57 
GeneralRe: Desingning a Dialog Box's and forms Pin
Niklas L22-Jul-10 6:20
Niklas L22-Jul-10 6:20 
GeneralRe: Desingning a Dialog Box's and forms Pin
rrthangavel22-Jul-10 23:30
rrthangavel22-Jul-10 23:30 
Questioninheritance question Pin
lune1222-Jul-10 3:37
lune1222-Jul-10 3:37 
AnswerRe: inheritance question Pin
Niklas L22-Jul-10 4:54
Niklas L22-Jul-10 4:54 
AnswerRe: inheritance question Pin
Aescleal22-Jul-10 5:11
Aescleal22-Jul-10 5:11 
GeneralRe: inheritance question Pin
Niklas L22-Jul-10 6:03
Niklas L22-Jul-10 6:03 
GeneralRe: inheritance question Pin
Moak22-Jul-10 14:30
Moak22-Jul-10 14:30 
GeneralRe: inheritance question Pin
Aescleal22-Jul-10 20:15
Aescleal22-Jul-10 20:15 
GeneralRe: inheritance question Pin
Moak23-Jul-10 0:25
Moak23-Jul-10 0:25 
GeneralRe: inheritance question Pin
Niklas L22-Jul-10 22:44
Niklas L22-Jul-10 22:44 
GeneralRe: inheritance question Pin
Aescleal22-Jul-10 20:17
Aescleal22-Jul-10 20:17 
GeneralRe: inheritance question Pin
Niklas L22-Jul-10 23:11
Niklas L22-Jul-10 23:11 
GeneralRe: inheritance question Pin
Aescleal23-Jul-10 4:13
Aescleal23-Jul-10 4:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.