c语言里面字符串结束符’\0’的值就是0,所以buf[buf_len] = 0相当于buf[buf_len] = ‘\0’;
const int buf_len=1024;
char buf[buf_len+1];
buf[buf_len]=0;
//这样就没越界
const int buf_len=1024;
char buf[buf_len];
buf[buf_len]=0;
//这样就越界了
c语言里面字符串结束符’\0’的值就是0,所以buf[buf_len] = 0相当于buf[buf_len] = ‘\0’;
const int buf_len=1024;
char buf[buf_len+1];
buf[buf_len]=0;
//这样就没越界
const int buf_len=1024;
char buf[buf_len];
buf[buf_len]=0;
//这样就越界了