唐嫣山寨礼服:编写程序 把数字字符串转换成整数
来源:百度文库 编辑:中科新闻网 时间:2024/07/02 03:17:19
#include "stdio.h"
void main()
{
char *s = new char[20];
scanf("%s",s);
int n=0;
while(*s!='\0')
{
n = n*10+*s-'0';
s++;
}
printf("%d\n",n);
}
atoi();
atof();
atod();
可以直接将字符串转变成数字;