VC编译器下如何解决error C2679、error C2676、error C2784、fatal error C1903错误

最近编写了一小段程序,在GNU编译器下能编译通过,但在VC编译器下却显示一大堆错误。查看编译信息,其中错误提示如下:
error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversion)
fatal error C1903: unable to recover from previous error(s); stopping compilation

这段程序如下所示,程序不断从stdin中读入单词,若该单词是第一次出现,则输出该单词,否则忽略。注:输入中单词以空格间隔,标点符号仅出现在单词后面,且和单词字母间没有其他字符。

例如输入:where there is a will, there is a way.

则应输出:where there is a will way

#include <iostream>
#include <cstring>
#include <set>
using namespace std;

int main()
{
    char str[100];
    string word;
    set<string> words;
    while(cin >> str){
	int n = strlen(str) - 1;
	char c = str[n];
	if (!isa
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值