字符转数字
#include <stdio.h> #include <stdlib.h> int transform(char str[]){ int i = 0; int result = 0; while(str[i] != '\0'){ result = result * 10 + str[i] - '0'; i++; } return result; } main(){ char* str = "1234"; int result; result = transform(str); printf("%d \n", result); }