在C语言中,可以使用库函数atoi来将字符转换成整数。atoi函数的原型如下:
int atoi(const char *str);其中,str是要转换的字符数组(字符串),函数会将其转换成对应的整数并返回。例如:
#include <stdio.h>#include <stdlib.h>int main() { char str[] = "12345"; int num = atoi(str); printf("转换后的整数为: %d\n", num); return 0;}上述代码中,将字符串"12345"转换成整数并打印出来。


