atoi()字符串转换为整数 _itoa_s()整数转换为字符串

//atoi()函数将字符串转换成整型数。当第一个字符不能识别为数字时,函数将停止读入输入字符串。
char
*a1 = "123"; char *a2 = "1 23"; char *a3 = "-123"; char *a4 = "a123"; char *a5 = "123b"; char *a6 = "12a3"; int b1 = atoi(a1);//123 int b2 = atoi(a2);//1 int b3 = atoi(a3);//-123 int b4 = atoi(a4);//0 int b5 = atoi(a5);//123 int b6 = atoi(a6);//12

 

//_itoa_s()原型。将整数转换为字符串
_Check_return_opt_ _CRTIMP errno_t __cdecl _itoa_s(
    _In_ int _Value, 
    _Out_writes_z_(_Size) char * _DstBuf, 
    _In_ size_t _Size, 
    _In_ int _Radix);

 

posted on 2017-03-15 16:14  czhoud  阅读(244)  评论(0编辑  收藏  举报

导航