![]() |
PCDVD數位科技討論區
(https://www.pcdvd.com.tw/index.php)
- 疑難雜症區
(https://www.pcdvd.com.tw/forumdisplay.php?f=34)
- - C語言的char要怎麼轉int?
(https://www.pcdvd.com.tw/showthread.php?t=401564)
|
|---|
C語言的char要怎麼轉int?
請問一下唷…在其他語言…都有函式能將字串轉數值(當然啦…輸入的一定是數字)
C要怎麼轉啊? |
試試看 atoi() function.
必須包含 stdlib.h header file for example, #include <iostream.h> #include <stdlib.h> int main() { char a = 'A'; int b = atoi(a); printf(b); return 0; } |
應該能使用 atoi() 吧
如:atoi( string ); 印象中是定義在<stdlib.h>這個標頭檔裡 |
| 所有的時間均為GMT +8。 現在的時間是12:33 PM. |
vBulletin Version 3.0.1
powered_by_vbulletin 2026。