C Tutorial/printf scanf/printf Escape Sequence — различия между версиями
Admin (обсуждение | вклад) м (1 версия: Импорт контента...) |
|
(нет различий)
|
Текущая версия на 10:32, 25 мая 2010
Содержание
- 1 \a: Produces a beep or flash; the cursor position is not changed.
- 2 \b: Moves the cursor to the last column of the previous line.
- 3 Escape Sequence
- 4 \f: Moves the cursor to start of next page.
- 5 \ for quotation
- 6 \n: New line
- 7 %%: Prints %.
- 8 \\: Prints single \
- 9 \r: Carriage Return (Moves the cursor to the first column of the current line.)
- 10 \t: Horizontal Tab
- 11 \v: Vertical Tab
\a: Produces a beep or flash; the cursor position is not changed.
#include <stdio.h>
main()
{
printf("\a %d", 25);
printf("AAA");
}
25AAA
\b: Moves the cursor to the last column of the previous line.
#include <stdio.h>
main()
{
printf("\b %d", 25);
printf("AAA");
}
25AAA
Escape Sequence
Escape sequences are the special directives used to format printing.
For example, \n indicates that the next printing should start from the first column of the next line.
4.11.printf Escape Sequence 4.11.1. Escape Sequence 4.11.2. <A href="/Tutorial/C/0080__printf-scanf/aProducesabeeporflashthecursorpositionisnotchanged.htm">\a: Produces a beep or flash; the cursor position is not changed.</a> 4.11.3. <A href="/Tutorial/C/0080__printf-scanf/bMovesthecursortothelastcolumnofthepreviousline.htm">\b: Moves the cursor to the last column of the previous line.</a> 4.11.4. <A href="/Tutorial/C/0080__printf-scanf/fMovesthecursortostartofnextpage.htm">\f: Moves the cursor to start of next page.</a> 4.11.5. <A href="/Tutorial/C/0080__printf-scanf/nNewline.htm">\n: New line</a> 4.11.6. <A href="/Tutorial/C/0080__printf-scanf/rCarriageReturnMovesthecursortothefirstcolumnofthecurrentline.htm">\r: Carriage Return (Moves the cursor to the first column of the current line.)</a> 4.11.7. <A href="/Tutorial/C/0080__printf-scanf/tHorizontalTab.htm">\t: Horizontal Tab</a> 4.11.8. <A href="/Tutorial/C/0080__printf-scanf/vVerticalTab.htm">\v: Vertical Tab</a> 4.11.9. <A href="/Tutorial/C/0080__printf-scanf/Printssingle.htm">\\: Prints single \</a> 4.11.10. <A href="/Tutorial/C/0080__printf-scanf/forquotation.htm">\ for quotation</a> 4.11.11. <A href="/Tutorial/C/0080__printf-scanf/Prints.htm">%%: Prints %.</a>
\f: Moves the cursor to start of next page.
#include <stdio.h>
main()
{
printf("\f %d", 25);
printf("AAA");
}
25AAA
\ for quotation
#include <stdio.h>
main()
{
printf("\" %d", 25);
}
" 25
\n: New line
#include <stdio.h>
main()
{
printf("\n %d", 25);
}
25
%%: Prints %.
#include <stdio.h>
main()
{
printf("%d %%", 25);
}
25 %
\\: Prints single \
#include <stdio.h>
main()
{
printf("\\ %d", 25);
}
\ 25
\r: Carriage Return (Moves the cursor to the first column of the current line.)
#include <stdio.h>
main()
{
printf("\r %d", 25);
}
25
\t: Horizontal Tab
#include <stdio.h>
main()
{
printf("\t %d\tA\t", 25);
}
25 A
\v: Vertical Tab
#include <stdio.h>
main()
{
printf("\v %d", 25);
printf("AAA");
}