C언어 문자 리터럴 사이즈

John Jeong (토론 | 기여)님의 2017년 5월 14일 (일) 00:47 판 (→‎C++)

1 개념

문자 리터럴 사이즈
  • 'a'와 같은 문자 리터럴 사이즈 확인

2 C

#include <stdio.h>
#include <string.h>

int main()
{
    printf("%lu\n", sizeof('a')); // 4
    printf("%lu\n", sizeof(int)); // 4

   return 0;
}

3 C++

#include <iostream>
using namespace std;

int main()
{
    cout << sizeof('a') << endl; // 1
    cout << sizeof(char) << endl; // 1
}

4 참고 자료

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