strlen과 sizeof의 차이
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #include #include int main() { char buf[1024]; memset(buf, 0, sizeof(buf)); printf("len = %d\n", strlen(buf)); printf("size = %d\n", sizeof(buf)); strncpy(buf, "hello world\n", sizeof(buf)); printf("%s\n", buf); printf("len = %d\n", strlen(buf)); printf("size = %d\n", sizeof(buf)); return 0; } Colored by Color Scripter cs sizeof는 말그대로 buf의 사이즈를 출력하고, ..
2019. 5. 27. 23:09