|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
下面的例子。。。。为什么用VC++编译不能通过。。提示 error C2440: “=”: 无法从“const char *”转换为“int”
可是在unix系统下确能编译通过。。而且运行无误。。。。。
要怎么才能在VC++中顺利使用呢?? 求教育~~~~~
- #include "stdafx.h"
- #include "ctype.h"
- int str2int(const char* str,const char** q)
- {
- int r=0;
- while(isdigit(*str))
- {
- r = r*10+(str-'0'); //error C2440: “=”: 无法从“const char *”转换为“int”
- ++str;
- }
- *q = str;
- return r;
- }
- int main()
- {
- const char* p=NULL;
- int n =str2int("3926abxys",&p);
- printf("n=%d, p=%s \n",n,p);
- return 0;
- }
复制代码
|
|