#include<stdio.h> void main() {char p[]={'a','b','c'},q[10]={'a','b','c'};

日期:2018-03-20 20:03:34 人气:2

#include<stdio.h> void main() {char p[]={'a','b','c'},q[10]={'a','b','c'};

我有运行的结果是15 3,知道为什么吗? 因为strlen是用来计算字符串长度的,也就是说读到 '\0' 才计算长度,由于 p[] 的长度是未知的,因此strlen出来的结果也是未知的,而 q[] 在最后自动帮你补了个 '\0',因此读出来是3
    A+
热门评论