环境描写好句子大全:编写程序 把数字字符串转换成整数
来源:百度文库 编辑:高校问答 时间:2024/05/09 06:47:15
#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();
可以直接将字符串转变成数字;