读书人

windows程序设计这样错哪了

发布时间: 2012-04-02 19:58:59 作者: rapoo

windows程序设计,这样哪里错了?
刚学windows程序设计,工具vc++6.0,想定义一个string 类,
已引入#include 《string》,

code:

char buff[100]={'\0'};
char buff2[10]={'\0'};
string temp=NULL;
char * end1=NULL,end2=NULL;

编译错误:
F:\mfc\math\math.cpp(140) : error C2146: syntax error : missing ';' before identifier 'temp'
F:\mfc\math\math.cpp(140) : error C2501: 'string' : missing storage-class or type specifiers
F:\mfc\math\math.cpp(140) : fatal error C1004: unexpected end of file found

[解决办法]
string 需要加 namespace,即 std

比如 std::string temp;

或者在开始处加上 using std::string 或 using namespace std;
[解决办法]

temp.resize(0);
OK.
[解决办法]

探讨
编译通过了,运行什么结果也没有,这个为什么啊??
加了 getchar()也没有用。

[解决办法]
哈哈,楼上有道理

读书人网 >C++

热点推荐