• 코드:
​x
 
1
#include <stdio.h>
2
#include <string.h>
3
​
4
int main(void)
5
{
6
    char str01[20] = "C language is ";  // 널 문자를 포함하여 15문자
7
    char str02[] = "Cool! and funny!";
8
        
9
    //strcat(str01, str02);     // 이 부분의 주석 처리를 삭제한 후 실행시키면 배열 오버플로우가 발생함 
10
    strncat(str01, str02, 5);   // 이렇게 최대 허용치를 설정해 놓으면 배열 오버플로우에 대해서는 안전해짐 
11
    puts(str01);
12
    return 0;
13
}
14
​
표준입력 & 실행옵션