😸

[C] atoll 関数

に公開

機能

文字列を long long int 型に変換する関数[1]

使用例

12345678901234 と表示する

\n は改行を表す エスケープシーケンス[2]

コード

printf("%lld\n", atoll("12345678901234"));
全文
#include <stdio.h>
#include <stdlib.h>
void main() {
    printf("%lld\n", atoll("12345678901234"));
}

実行結果

12345678901234

9876543210 を変数から表示する

コード

char str[] = "9876543210";
printf("%lld\n", atoll(str));
全文
#include <stdio.h>
#include <stdlib.h>
void main() {
    char str[] = "9876543210";
    printf("%lld\n", atoll(str));
}

実行結果

9876543210
脚注
  1. atoll関数は文字列をlong long int型の値に変換する。文字列が数字でない場合は0を返すことが多い。 ↩︎

  2. 改行やタブなど、画面に表示されない制御文字のこと。 ↩︎

Discussion