gcc编译c++程序报错,什么原因?
#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;
}
debian:~# gcc prog1.cpp
prog1.cpp:12:2: warning: no newline at end of file
prog1.cpp: In function ‘int main()’:
prog1.cpp:8: error: no match for ‘operator> > ’ in ‘std::cout > > "word read is: "’
prog1.cpp:10: error: no match for ‘operator> > ’ in ‘std::cout > > "ok: no more words to read: bye!\012 "’
------解决方案--------------------1. 编译c++程序用g++编译器
2. 输出操作符写反了-_-!
------解决方案--------------------#include <iostream>
#include <string>
using namespace std;
int main() {
string word;
while (cin > > word) {
//cout > > "word read is: " > > word > > "\n ";
cout < < "word read is: " < < word < < "\n ";
}
//cout > > "ok: no more words to read: bye!\n ";
cout < < "ok: no more words to read: bye!\n ";
return 0;
}
那个报错信息说的很清楚呀.....
编译器用错了...
------解决方案--------------------> > 改为 < <
------解决方案--------------------怎么写成这样了啊
刚学C++吧,还得努力啊
< <重载 "ok: no more words to read: bye!\n "参数
我理解的
大家一起努力学习...
------解决方案--------------------gcc -o pro prog1.cpp -lstdc++
------解决方案--------------------请问为什么在集群上编译程序出错的提示是乱码?
main.cpp:13: error: stray 鈂163?in program
main.cpp:13: error: stray 鈂172?in program
main.cpp: In function 鈏nt main()?
main.cpp:13: error: variable 鈙td::ifstream infile?has initializer but incomplete type
这是什么意思?