題組內容

二、請回答下列 C 語言程式問題:

⑷請問若是要使用 C 語言標準函式庫的 atoi()函式,需要引入那個標頭檔(header file)?(5 分)

詳解 (共 2 筆)

Clown(2021上岸
Clown(2021上岸
詳解 #3475458
2019/07/11
#include <stdlib....
(共 67 字,隱藏中)
前往觀看
hchungw
hchungw
詳解 #6051929
2024/03/23
在C語言中,要使用atoi()函數,需要引入標頭檔stdlib.h。這個函數用於將字串轉換成整數(int)。這裡是一個例子:
c
Copy code
#include <stdlib.h>
int main() {
    char str[] = "123";
    int num = atoi(str);
    // num 現在是整數 123
    return 0;
}