关于将字符串转换成整数的咨询
你好
我在网上差了下atoi()这个函数能够将字符串转成整数,但是我试了下,
n=atoi(str);输入的n=0;不是我输入的整数,请问这是哪里出问题了。
工程建立的是c++控制台应用程序
// te.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "stdlib.h"
int _tmain(int argc, _TCHAR* argv[])
{
int n;
char *str="0f12";
n=atoi(str);
printf("string=%sinteger=%d\n",str,n);
return 0;
}
输出结构:
string=0f12integer=0
请按任意键继续. . .
谢谢!