C语言字符串转整数:使用 atoi 函数
你可以使用 C 语言的标准库函数 'atoi' 来将字符串转换为整数。下面是一个示例代码:
#include <stdio.h>
#include <stdlib.h>
int main() {
char str[] = '1234';
int num = atoi(str);
printf('%d\n', num);
return 0;
}
输出结果为:
1234
原文地址: https://www.cveoy.top/t/topic/qgta 著作权归作者所有。请勿转载和采集!