#include <stdio.h>

int main() {
    // 자료형 배열이름[배열크기]
    char str1[] = "coding";
    printf("%s\n", str1);
    // 문자열의 가장 마지막에는 널null문자 \0가 들어있다
    // 널null문자 : 문자열의 끝을 알려주는 문자
    printf("%ld\n", sizeof(str1));

    for (int i = 0; i < sizeof(str1); i++) {
        printf("%d ", str1[i]); //아스키 코드
    }
    printf("\n");

    char kor[] = "임이랑";
    printf("%s\n", kor);
    printf("%ld\n", sizeof(kor));
    // 한글은 한 글자 당 3바이트 + \0

    printf("----문제----\n");
    char eng[] = "hello";

    // 문자열 출력
    printf("%s\n", eng);

    // 배열의 크기 출력
    printf("%ld\n", sizeof(eng));

    // 각 문자를 한 줄씩 출력
    for (int i = 0; i < sizeof(eng); i++) {
        printf("%c ", eng[i]);
    }
    
    
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: