#include <stdio.h>
#include <stdbool.h>
int main(void){
bool a = true;
printf("bool value is %d \n", a);
char name[2];
scanf("%s", &name[0]);
printf("name is %s \n", name);
printf("char is %s", name[5]);
}
我的那个字符串长度为2.为什么可以接受很长的字符串。
比如我运行的 时候输入helloworld 那么输出printf("name is %s \n", name); 可以输出helloworld 但是name[5]就会提示段错误??
%s是一直输出到\0才终止intent:#Intent;S.K_1171477665=57AC7D74F5F3A45EE3A66AF7A1EF75E6B3866417FEE80745E115483E0A37CC72;end