scanf_s、wscanf_s
stdio.h:インデックス への移動
ヘッダー ファイル
stdio.h
カテゴリ
書式付き入出力関数
プロトタイプ
int scanf_s(const char * restrict format,[, address, ...]);
int wscanf_s(const wchar_t * restrict format,[, address, ...]);
説明
scanf、wscanf の代わりとなる、セキュリティを強化した関数です。
メモ:Win32 GUI アプリケーションの場合、stdin をリダイレクトする必要があります。
scanf_s は、fscanf_s、fwscanf_s と同等のものですが、stream の代わりに stdin が引数として使われます。
戻り値
成功すると、scanf_s は、スキャン、変換、格納が成功した入力フィールドの数を返します。 成功しなければ、EOF マクロの値を返します。
例
#include <stdio.h> int main(void) { int x; printf_s("int: "); scanf_s("%d", &x); printf_s("the number is: %d", x); return 0; }