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

求解,这代码在vC6.0中运行不起来,明明是按书上一行一行抄下来的。

夜十天 发布于 2013-11-09 11:06, 468 次点击
#include "stdafx.h"
#include "iostream"
#include "string"
int main()
{   using namespace std;
    char charr1[20];
    char charr2[20];
    string str1;
    string str2="panther";
    cout<<"Enter a kind of feline:"<<endl;
    cin>>charr1;
    cout<<"Enter another kind of feline:"<<endl;
    cin>>str1;
    cout<<"Here are some felines\n";
    cout<<charr1<<" "<<charr2<<" "<<str1<<" "<<str2<<endl;
    cout<<"The third letter in"<<charr2<<"is"<<charr2[2]<<endl;
    cout<<"The ghird letter in"<<str2<<"is">>str2[2]<<endl;
    return 0;
}
这是错误信息提醒:
D:\新建文件夹\Microsoft Visual Studio\MyProjects\999\999.cpp(20) : error C2676: binary '>>' : 'class std::basic_ostream<char,struct std::char_traits<char> >' does not define this operator or a conversion to a type acceptable to the predefined operat
or
执行 cl.exe 时出错.

999.exe - 1 error(s), 0 warning(s)
求大神。
4 回复
#2
rjsp2013-11-09 12:08
什么鸟书会写 #include "stdafx.h" ?
什么鸟书会写 #include "iostream" 而不是 #include <iostream> ?
什么鸟书会写 cout<<"The ghird letter in"<<str2<<"is">>str2[2]<<endl; ?
#3
peach54602013-11-09 13:19
以下是引用rjsp在2013-11-9 12:08:08的发言:

什么鸟书会写 #include "stdafx.h" ?
什么鸟书会写 #include "iostream" 而不是 #include  ?
什么鸟书会写 cout<<"The ghird letter in"<>str2[2]<

+1
#4
blueskiner2013-11-09 13:32
以下是引用rjsp在2013-11-9 12:08:08的发言:

什么鸟书会写 #include "stdafx.h" ?
什么鸟书会写 #include "iostream" 而不是 #include <iostream> ?
什么鸟书会写 cout<<"The ghird letter in"<<str2<<"is">>str2[2]<<endl; ?

+1
#5
左手拉一只猫2013-11-09 15:08
回复 2楼 rjsp
+1
1