新微赢技术网
标题:
[em03]string类的输入问题
[打印本页]
作者:
蓝血腥人
时间:
2009-11-3 01:45
标题:
[em03]string类的输入问题
小弟请教下一个string类怎么实现输入啊 有库函数吗?
紧急啊 大哥们
作者:
熾天使rose
时间:
2009-11-3 01:45
利用字符数组间接输入,比如
#include "iostream.h"
#include "afx.h"
void main()
{char c[80];
CString st1;
cout<<"输入字符串:";
cin>>c;
st1=c;
cout<<"输出结果:";
cout <<st1<<endl;
}
作者:
飘香剑雨
时间:
2009-11-3 01:45
直接就可以输入啊
#include <string>
using namespace std;
void main()
{
string str;
cin>>str;
cout<<str;
}
作者:
30岁就改变
时间:
2009-11-3 01:45
用了楼上的程序怎么报错啊?
--------------------Configuration: yes - Win32 Debug--------------------
Compiling...
yes.cpp
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(6) : error C2065: 'cin' : undeclared identifier
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(6) : error C2784: 'class std::basic_istream<_E,_Tr> &__cdecl std::operator >>(class std::basic_istream<_E,_Tr> &,class std::basic_string<_E,_Tr,_A> &)' : could not deduce template argument for 'cl
ass std::basic_istream<_E,_Tr> &' from 'int'
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(6) : error C2784: 'class std::basic_istream<_E,_Tr> &__cdecl std::operator >>(class std::basic_istream<_E,_Tr> &,short *)' : could not deduce template argument for 'class std::basic_istream<_E,_Tr
> &' from 'int'
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(6) : error C2784: 'class std::basic_istream<_E,_Tr> &__cdecl std::operator >>(class std::basic_istream<_E,_Tr> &,unsigned char &)' : could not deduce template argument for 'class std::basic_istrea
m<_E,_Tr> &' from 'int'
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(6) : error C2784: 'class std::basic_istream<_E,_Tr> &__cdecl std::operator >>(class std::basic_istream<_E,_Tr> &,unsigned char *)' : could not deduce template argument for 'class std::basic_istrea
m<_E,_Tr> &' from 'int'
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(6) : error C2784: 'class std::basic_istream<_E,_Tr> &__cdecl std::operator >>(class std::basic_istream<_E,_Tr> &,signed char &)' : could not deduce template argument for 'class std::basic_istream<
_E,_Tr> &' from 'int'
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(6) : error C2784: 'class std::basic_istream<_E,_Tr> &__cdecl std::operator >>(class std::basic_istream<_E,_Tr> &,signed char *)' : could not deduce template argument for 'class std::basic_istream<
_E,_Tr> &' from 'int'
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(6) : error C2784: 'class std::basic_istream<_E,_Tr> &__cdecl std::operator >>(class std::basic_istream<_E,_Tr> &,_E &)' : could not deduce template argument for 'class std::basic_istream<_E,_Tr> &
' from 'int'
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(6) : error C2784: 'class std::basic_istream<_E,_Tr> &__cdecl std::operator >>(class std::basic_istream<_E,_Tr> &,_E *)' : could not deduce template argument for 'class std::basic_istream<_E,_Tr> &
' from 'int'
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(6) : error C2677: binary '>>' : no global operator defined which takes type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable con
version)
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(7) : error C2065: 'cout' : undeclared identifier
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(7) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const class std::basic_string<_E,_Tr,_A> &)' : could not deduce template argument f
or 'class std::basic_ostream<_E,_Tr> &' from 'int'
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(7) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const short *)' : could not deduce template argument for 'class std::basic_ostream<
_E,_Tr> &' from 'int'
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(7) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const unsigned char)' : could not deduce template argument for 'class std::basic_os
tream<_E,_Tr> &' from 'int'
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(7) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const unsigned char *)' : could not deduce template argument for 'class std::basic_
ostream<_E,_Tr> &' from 'int'
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(7) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const signed char)' : could not deduce template argument for 'class std::basic_ostr
eam<_E,_Tr> &' from 'int'
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(7) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const signed char *)' : could not deduce template argument for 'class std::basic_os
tream<_E,_Tr> &' from 'int'
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(7) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,_E)' : could not deduce template argument for 'class std::basic_ostream<_E,_Tr> &'
from 'int'
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(7) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const _E *)' : could not deduce template argument for 'class std::basic_ostream<_E,
_Tr> &' from 'int'
f:\visual c++6.0\vc++\msdev98\myprojects\yes\yes.cpp(7) : error C2677: binary '<<' : no global operator defined which takes type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable con
version)
执行 cl.exe 时出错.
yes.exe - 1 error(s), 0 warning(s)
作者:
︶ぺ雨湮ㄣ
时间:
2009-11-3 01:45
以下是引用lbwxqh在2006-4-29 12:28:00的发言:
直接就可以输入啊
#include <string>
#include<iostream>
using namespace std;
void main()
{
string str;
cin>>str;
cout<<str;
}
作者:
lala
时间:
2009-11-3 01:45
可以调用函数为sting类变量赋值吗???
欢迎光临 新微赢技术网 (http://bbs.weiying.cn/)
Powered by Discuz! X3.2