一.字符串获取
1.字符串数组
char arr[][6]{"hello","world"};
char arr[]={112,113,114,0,108,109};
输入为 pqr
char 字符类型的获取 遇到0则表示结束
①接受有空格的字符串gets
②scanf("%[^\n]") 正则表达式,接受非\n的字符
③fgets
可以接受空格
获取字符串少于元素个数会有\n,大于等于没有\n
自动补充0进行结尾,数据安全,不会造成缓存区溢出
3.字符串打印
①puts
puts("hello\0 world");
输入为 hello
puts 遇到\0会判定结束,并且会自动补充\n换行
fputs 不会自动补充\n
4.字符串长度
strlen
char arr[100]={"hello world"};
printf("%d",sizeof(arr));
printf("%d",strlen(arr));
输入结果 100 11
sizeof 输出的为数组长度
strlen输出的为字符串长度