#include <string>int main()
{
string word;
return 0;
} 请问这个程序为什么,不能在vc6里面编译呀,
错误信息是:
error C2065: 'string' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'word'
error C2065: 'word' : undeclared identifier要使用string类型,不是写#include <string>这句话就可以了吗?
{
string word;
return 0;
} 请问这个程序为什么,不能在vc6里面编译呀,
错误信息是:
error C2065: 'string' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'word'
error C2065: 'word' : undeclared identifier要使用string类型,不是写#include <string>这句话就可以了吗?
#include <string>
using namespace std;int main()
{
string word;
return 0;
} 像上面的.
你用#include<string>后面一定要有using namespace std;
或者这样: #include<string.h> (后面一定不要using namespace std;)
定义一个指向字符串的指针,如:char * word
同时也不必要预处理#include <string.h>
在VC中有 string.h (在VC中新增加的一个关于string操作的类)
和 cstring.h (与原C语言中的string.h一样的功能,前面加"c"是为了区别于C语言.
其它的从C中沿用的头文件一般都是在前面加上c,以示区别)
这两个头文件.
我看了string.h,里面却没有一个函数的返回类型和参数表是有string类型的!!
或者 std::string word; 不用加using namespace std;