c,

[C] printf, format specifier 서식 지정자

Software-engineer Software-engineer Follow Dec 02, 2020 · 1 min read
[C] printf, format specifier 서식 지정자
Share this

The letter f in printf stands for formatted, meaning that you can format the output. The output format can be specified by inserting the format specifier content between “ “. Representative format specifiers are shown in the table below.

printff 는 formatted의 약자이며 출력에 대한 서식을 지정할 수 있음을 의미한다. 출력 서식은 “ “ 사이에 서식 지정자 내용과 함께 삽입하여 지정할 수 있다. 대표적인 서식 지정자는 아래 표와 같다.

Syntax Meaning 의미
\n New line 줄바뀜
\r Carriage Return 행의 맨 앞으로 이동
\t Tab
\b Back 이전으로 한 칸 이동
\0 Null Null문자
\ Backslash return 백슬래시 출력
' Single quotation return 따움표 출력
" Double quotation return 큰 따음표 출력
%% Percentage return 퍼센트 출력
    #include <stdio.h>

    int main(void){
        printf("Hello World\n");
        printf("Hello \nWorld\n");
        printf("Hello \rWorld\n");
        printf("Hello \tWorld\n");
        printf("Hello \bWorld\n");
        printf("\\n Hello World\n");
        printf("\'Hello World\'\n");
        printf("\"Hello World\"\n");  
        printf("Hello %%World\n");

        return 0;
    }   
Hello World
Hello
World
World
Hello   World
HelloWorld
\n Hello World
'Hello World'
"Hello World"
Hello %World

Software-engineer
Written by Software-engineer
Software engineer Youn