#include "stdio.h"
#include "stdlib.h"
#include "string.h"
int main(void)
{
char *str = (char *)malloc(sizeof(char)*30);
int i;
int res = 0;
str = "12345";
int len = strlen(str);
for(i=0;i<len;i++)
{
res = str[i]-'0';//转化关键:res = str[i] - '0';
printf("res = %d\n",res);
}
return 0;
}
C语言将一个字符串的字符转为一个数字
最新推荐文章于 2024-04-13 06:04:17 发布