有這樣的庫函數的
頭文件 stdlib.h
字符串轉換函數 函數列表
函數用途 函數名
字符串轉換為整數 atoi
字符串轉換為長整數 atol
字符串轉換為浮點數 strtod
字符串轉換為長整數 strtol
字符串轉換為無符號長整型 strtoul
例程:
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
int n;
char *str = "12345.67";
n = atoi(str);
printf("string = %s integer = %d\n", str, n);
return 0;
}