strcat越界不产生异常,但修改相临存储区的内容

时间:2022-08-19 15:04:17
#include < stdio.h >
#include
< string .h >
int  main(){
    
char  p[]  =   " iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii " ;
    
char  flower1[ 5 ];
    
char  s1[] = " lixiangfu " ;
    printf(
" p:%p,flower1:%p,s1:%p " ,p,flower1,s1);
    
char  addon[] = " s smell like old shoes. " ;
    gets(flower1);
    strcat(flower1,addon);
    puts(flower1);
    puts(s1);
    puts(p);
    getchar();
    
return   0 ;
}

数组p变成了"ell like shoes."

就是因为strcat中flower1漫溢的数据