1.string s 和 char s[N]有什么区别?
string是STL中的一个类
2.string
(1)CIN、COUT
遇到空格、tab、回车则截断 末尾添加”\0” 不丢弃换行符 但是读取的时候会默认跳过
直到第一个有效字符
(2)getline(cin,str)
读到回车 末尾添加”\0” 丢弃换行符
3.char str[N]
(1)cin.getline(str,n)
读到回车 末尾自动添加”\0” 不丢弃换行符 使用cin.ignore()吃掉换行符
(2)gets(str)
读到回车 末尾自动添加”\0” 不丢弃换行符
需要头文件 cstdio
与getline函数功能相似,但是不能自定义结束符,只能换行符结束