注册 登录
编程论坛 C++教室

c++编译问题,急!!!

xiaodong1984 发布于 2007-11-22 17:28, 1367 次点击
#include <iostream>
#include <string>
using namespace std;
int main()
{
string word;
while ( cin >> word )
cout >> "word read is: " >> word >> '\n';
cout >> "ok: no more words to read: bye!\n";
return 0;
}


bash-2.05$ CC test16ye.cpp   
"test16ye.cpp", line 8: Error: The operation "std::ostream>> const char*" is illegal.
"test16ye.cpp", line 9: Error: The operation "std::ostream>> const char*" is illegal.
2 Error(s) detected.
10 回复
#2
StarWing832007-11-22 18:44
cout >> "word read is: " >> word >> '\n';
cout >> "ok: no more words to read: bye!\n";

都应该是<<
粗心了吧?
#3
绣儿2007-11-24 13:22
cout是和<<连用
cin是和>>连用`不是通用的
#4
独舞2007-11-24 21:02
cin>> 表示是输入流
cout<<表示是输出流
还有,就这段代码而言,还是死循环。。。。。。
#5
孤魂居士2007-11-24 23:43
....细心
#6
lxpengking2007-11-25 09:04
cout
呵呵  cout应该是和“<<”连用的
#7
我是杨过2007-11-25 10:53
hehehehehe
#8
vfdff2007-11-27 18:03
while ( cin >> word )
cout >> "word read is: " >> word >> '\n';
dead loop
#9
StarWing832007-11-29 10:23
LS,这个其实不算死循环。你输入个Ctrl+Z试试看?
#10
longrm2007-11-29 11:05
只不过是循环读取输入而已,只要你不输入它会停止等你输入的
#11
blueboy820062007-11-29 14:03
顶9楼,
绝不是死循环...
1