C언어 printf()

Jmnote (토론 | 기여)님의 2023년 8월 18일 (금) 19:13 판
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

#include <stdio.h>
int main()
{
    printf("Hello World!"); // Hello World!
}
#include <stdio.h>
int main()
{
    int x = 42;
    printf("answer=[%d]", x); // answer=[42]
}
#include <stdio.h>
int main()
{
    float distance = 42.195;
    printf("distance=[%f]\n", distance);   // distance=[42.195000]
    printf("distance=[%.0f]\n", distance); // distance=[42]
    printf("distance=[%.1f]\n", distance); // distance=[42.1]
    printf("distance=[%.2f]\n", distance); // distance=[42.19]
}

2 포맷문자[ | ]

%c character(문자)
%d dec(10진수 정수)
%f float(실수)
%o oct(8진수 정수)
%s string(문자열)
%x hex(16진수 정수)

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}