char与int转化

(1)字符串转换成数字,用atoi,atol,atof,分别对应的是整型,long型,double型。以整型为例:

char str[]="1234";
int a=atoi(str);

(2)数字换成字符串,用sprintf.以整型为例。

char str[10];
int a=1234;
sprintf(str,"%d",a);

你可能感兴趣的:(char与int转化)