We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
5.1.3 字符串 104页 提示5-5上方 原文是:
例如,C++的cin/cout可以直接读写string类型,却不能读写字符数组;string类型还可以像整数那样“相加”……
而在下面那份“输出每行所有整数之和”的代码中,有这样几行代码:
while(getline(cin,line)) { int sum = 0, x; stringstream ss(line); while(ss >> x) sum += x; cout << sum << "\n"; }
注意这里:
cout << sum << "\n";
"\n"本身就是一个“只有一个字符”的字符数组,而能写到cout里。这不与上面“不能读写字符数组”矛盾吗?仔细查一查iostream的资料,可以发现它们可以读写char*或者 char[] 建议作者改一下。。。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
5.1.3 字符串 104页 提示5-5上方
原文是:
而在下面那份“输出每行所有整数之和”的代码中,有这样几行代码:
注意这里:
cout << sum << "\n";
"\n"本身就是一个“只有一个字符”的字符数组,而能写到cout里。这不与上面“不能读写字符数组”矛盾吗?仔细查一查iostream的资料,可以发现它们可以读写char*或者 char[]
建议作者改一下。。。
The text was updated successfully, but these errors were encountered: