C언어 문자 리터럴 사이즈

1 개념[ | ]

문자 리터럴 사이즈
  • 'a' 문자를 통한 리터럴 사이즈 확인

2 C[ | ]

  • C언어에서는 문자 리터럴이 int와 동일하게 4바이트임
#include <stdio.h>
#include <string.h>

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

   return 0;
}

3 C++[ | ]

  • C++에서는 문자 리터럴이 char와 동일하게 1바이트임
#include <iostream>

using namespace std;

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

4 같이 보기[ | ]

5 참고[ | ]

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