Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
重複の可能性: C で単一の char を int Character から integer に 変換する方法
charaをに変換する方法を誰か教えてもらえますintか?
char
int
char c[]={'1',':','3'}; int i=int(c[0]); printf("%d",i);
これを試すと、49が得られます。
標準関数atoi()は、おそらくあなたが望むことをします。
atoi()
「atoi」を使用した簡単な例:
#include <stdlib.h> #include <unistd.h> int main(int argc, char *argv[]) { int useconds = atoi(argv[1]); usleep(useconds); }