トップページ > キーワード検索 > sscanf()
C言語規格
C言語(その他)
プログラム
その他
sscanf()
機能 指定の書式に従って引数の文字列からデータを取得することを表す。
定義 #include <stdio.h>

int sscanf ( const char * s, const char * format, ... );

※C99規格では以下の定義となる
int sscanf ( const char * restrict s, const char * restrict format, ... );
引数
s取得する文字列
format変換書式文字列。詳細はscanf関数を参照
...入力を格納する変数群(可変引数)
戻り値 代入された入力項目の個数を返す。
入力無しまたは入力誤りが発生した場合はEOFを返す。
実装例
#include <stdio.h>

int main(void)
{
    char s[] = "123";
    int n;
    
    sscanf(s, "%d", &n);
    
    printf("n=%d\n", n);
    
    return 0;
}
実行結果
n=123





inserted by FC2 system