Ãâ·Â ¾ç½Ä ÁöÁ¤ (Formatted output)

printf("control string", expr1, expr2, ... );

Control string¿¡ Æ÷ÇÔµÈ \¿Í % ±âÈ£´Â ¾ç½ÄÀ» °áÁ¤Çϴ Ư¼ö ±âÈ£·Î Ãë±Þ

%d, %i Decimal integer
%ld, %li Long integer
%O Octal
%x, %X Hexadecimal
%f Floating-point
%e, %E Exponential
%g, %G General, %f ¶Ç´Â %e Áß ÂªÀº Ç¥Çö »ç¿ë
%c Character
%s String
%% Percent sign

Ãâ·ÂÀÇ Å©±â¿Í Á¤¹Ðµµ ÁöÁ¤

Format
Output
%d456
%5d__456
%-5d456__
%2d456
%f123.456000
%12f__123.456000
%9.2f___123.45
%e1.234560e+02
%9.2E_1.23E+02
%sabcdefg
%10s___abcdefg
%-10sabcdefg___
%5sabcdefg
%5.5sabcde

Format string¿¡ Æ÷Ç﵃ ¼ö ÀÖ´Â special character

\aBell ¶Ç´Â alert character
\bbackspace
\fformfeed (start a new page)
\nnewline
\rcarriage return
\ttab
\vvertical tab
\\backslash (\)



ÀÔ·Â ¾ç½Ä ÁöÁ¤ (Formatted input)

scanf("control string", ÁÖ¼Ò1, ÁÖ¼Ò2, ... );

scanf functionÀ» ÀÌ¿ëÇØ data¸¦ ÀÔ·ÂÇϱâ À§Çؼ­´Â ÀÔ·ÂÇÒ data¸¦ ÀúÀåÇÒ º¯¼öÀÇ ¸Þ¸ð¸® ÁÖ¼Ò¸¦ argument·Î ÁÖ¾î¾ß ÇÑ´Ù.
scanf functionÀÇ formatÀº printf functionÀÇ format°ú À¯»çÇÏ¸ç ´ÙÀ½°ú °°ÀÌ Ã³¸®µÈ´Ù.



Standard I/O redirection°ú pipe (MS-DOS¿Í UNIX OS¿¡¼­ À¯¿ë)

Standard I/O·ÎºÎÅÍÀÇ ÀÔÃâ·ÂÀ» file ¶Ç´Â ¾Õ ÇÁ·Î¼¼½ºÀÇ Ãâ·ÂÀ¸·Î Àüȯ