名前空間
変種
操作

scanf, fscanf, sscanf

提供: cppreference.com
< c‎ | io

 
 
File input/output
機能します
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ファイルアクセス
Original:
File access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
直接入力/出力
Original:
Direct input/output
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
fread
fwrite
書式なし入力/出力
Original:
Unformatted input/output
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
書式付き入力/出力
Original:
Formatted input/output
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ファイル位置付け
Original:
File positioning
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ftell
fgetpos
fseek
fsetpos
rewind
エラー処理
Original:
Error handling
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
clearerr
feof
ferror
perror
ファイルに対する操作
Original:
Operations on files
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
remove
rename
tmpfile
tmpnam
 
Defined in header <stdio.h>
int scanf( const char *format, ... );
(1)
int fscanf( FILE *stream, const char *format, ... );
(2)
int sscanf( const char *buffer, const char *format, ... );
(3)
さまざまなソースからデータを読み込み、formatに従ってそれを解釈して、与えられた場所に結果を格納します.
Original:
Reads data from the a variety of sources, interprets it according to format and stores the results into given locations.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1)
stdinからデータを読み取ります
Original:
reads the data from stdin
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
ファイルストリームstreamからデータを読み取ります
Original:
reads the data from file stream stream
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
NULLで終わる文字列bufferからデータを読み取ります
Original:
reads the data from null-terminated character string buffer
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] パラメータ

stream -
から読み込むための入力ファイルストリーム
Original:
input file stream to read from
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
buffer -
から読み取るための、nullで終わる文字列へのポインタ
Original:
pointer to a null-terminated character string to read from
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
format -
入力を読み取る方法を指定するNULLで終わる文字列へのポインタ。
フォーマット文字列は、空白文字(フォーマット文字列内の任意の1つの空白文字は入力から利用可能なすべての連続した​​空白文字を消費します)、%以外の非空白文字(フォーマット文字列で、それぞれの文字が入力から正確に1つの同一の文字を消費する)で構成されていますと変換仕様。各変換仕様の形式は次のとおりです
Original:
The format string consists of whitespace characters (any single whitespace character in the format string consumes all available consecutive whitespace characters from the input), non-whitespace characters except % (each such character in the format strings consumes exactly one identical character from the input) and conversion specifications. Each conversion specification has the following format:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • 入門%文字
    Original:
    introductory % character
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • (オプション)代入抑制文字*。このオプションが指定されている場合、この関数は、すべての受信引数への変換の結果を代入しません.
    Original:
    (オプション) assignment-suppressing character *. If this option is present, the function does not assign the result of the conversion to any receiving argument.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 指定(オプション)整数(ゼロより大きい)フィールド最大幅、関数は現在の変換指定で指定した変換を行う際に消費するように許可されている文字の最大数です。幅が提供されていない場合、%sと%[はバッファオーバーフローにつながる可能性があることに注意してください.
    Original:
    (オプション) integer number (greater than zero) that specifies maximum field width, that is, the maximum number of characters that the function is allowed to consume when doing the conversion specified by the current conversion specification. Note that %s and %[ may lead to buffer overflow if the width is not provided.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 受信引数、つまり、実際の宛先タイプのサイズを指定し(オプション)長さ修飾子の。これは、変換精度とオーバーフロー規則に影響を与えます。デフォルトの宛先タイプ(次の表を参照)変換のタイプごとに異なっています.
    Original:
    (オプション) length modifier that specifies the size of the receiving argument, that is, the actual destination type. This affects the conversion accuracy and overflow rules. The default destination type is different for each conversion type (see table below).
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 変換書式指定子
    Original:
    conversion format specifier
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
次の書式指定子が用意されています
Original:
The following format specifiers are available:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Conversion
specifier
Explanation Argument type
length modifier hh h (none) l ll j z t L
% matches literal % N/A N/A N/A N/A N/A N/A N/A N/A N/A
c matches a single character N/A N/A
char*
wchar_t*
N/A N/A N/A N/A N/A
s matches a character string (a sequence of non-whitespace characters)
[set]
文字のsetから文字の非空のシーケンスと一致.
Original:
matches a non-empty sequence of character from set of characters.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
セットの最初の文字が^であれば、しないセット内のすべての文字が一致しています。セットは]で始まる場合、または^]その後]文字もセットに含まれています.
Original:
If the first character of the set is ^, then all characters not in the set are matched. If the set begins with ] or ^] then the ] character is also included into the set.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
d
'進整数'にマッチ.
Original:
matches a decimal integer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
番号の形式はstrtol()引数の値10baseによって予想と同じです
Original:
The format of the number is the same as expected by strtol() with the value 10 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
signed char* or unsigned char*
signed short* or unsigned short*
signed int* or unsigned int*
signed long* or unsigned long*
signed long long* or unsigned long long*
N/A
i
'進整数'にマッチ.
Original:
matches a decimal integer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
番号の形式はstrtol()引数の値0baseによって予想と同じです
Original:
The format of the number is the same as expected by strtol() with the value 0 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
u
'符号なし10進整数'にマッチ.
Original:
matches a unsigned decimal integer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
番号の形式はstrtoul()引数の値0baseによって予想と同じです
Original:
The format of the number is the same as expected by strtoul() with the value 0 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
o
'8進整数'と一致.
Original:
matches an octal integer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
番号の形式はstrtol()引数の値8baseによって予想と同じです
Original:
The format of the number is the same as expected by strtol() with the value 8 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
x
'16進整数'にマッチ.
Original:
matches an hexadecimal integer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
番号の形式はstrtol()引数の値16baseによって予想と同じです
Original:
The format of the number is the same as expected by strtol() with the value 16 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
n
'これまでに読ん文字数'を返します。.
Original:
returns the number of characters read so far.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
入力は使用されません。割り当てカウントをインクリメントしません。指定子が定義代入抑制演算子を持っている場合、動作は未定義です
Original:
No input is consumed. Does not increment the assignment count. If the specifier has assignment-suppressing operator defined, the behavior is undefined
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
a, A
e, E
f, F
g, G
'浮動小数点数を'と一致.
Original:
matches a floating-point number.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
strtof()によって予想通り番号の形式は同じです
Original:
The format of the number is the same as expected by strtof()
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A N/A
float*
double*
N/A N/A N/A N/A
long double*
p
を定義する実装定義の文字シーケンスに一致 'ポインタを'.
Original:
matches implementation defined character sequence defining a pointer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
機能のprintf家族が%p書式指定子を使用して、同じシーケンスを生成する必要があります
Original:
printf family of functions should produce the same sequence using %p format specifier
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A N/A
void**
N/A N/A N/A N/A N/A N/A
Original:
pointer to a null-terminated character string specifying how to read the input.
フォーマット文字列は、空白文字(フォーマット文字列内の任意の1つの空白文字は入力から利用可能なすべての連続した​​空白文字を消費します)、%以外の非空白文字(フォーマット文字列で、それぞれの文字が入力から正確に1つの同一の文字を消費する)で構成されていますと変換仕様。各変換仕様の形式は次のとおりです
Original:
The format string consists of whitespace characters (any single whitespace character in the format string consumes all available consecutive whitespace characters from the input), non-whitespace characters except % (each such character in the format strings consumes exactly one identical character from the input) and conversion specifications. Each conversion specification has the following format:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • 入門%文字
    Original:
    introductory % character
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • (オプション)代入抑制文字*。このオプションが指定されている場合、この関数は、すべての受信引数への変換の結果を代入しません.
    Original:
    (オプション) assignment-suppressing character *. If this option is present, the function does not assign the result of the conversion to any receiving argument.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 指定(オプション)整数(ゼロより大きい)フィールド最大幅、関数は現在の変換指定で指定した変換を行う際に消費するように許可されている文字の最大数です。幅が提供されていない場合、%sと%[はバッファオーバーフローにつながる可能性があることに注意してください.
    Original:
    (オプション) integer number (greater than zero) that specifies maximum field width, that is, the maximum number of characters that the function is allowed to consume when doing the conversion specified by the current conversion specification. Note that %s and %[ may lead to buffer overflow if the width is not provided.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 受信引数、つまり、実際の宛先タイプのサイズを指定し(オプション)長さ修飾子の。これは、変換精度とオーバーフロー規則に影響を与えます。デフォルトの宛先タイプ(次の表を参照)変換のタイプごとに異なっています.
    Original:
    (オプション) length modifier that specifies the size of the receiving argument, that is, the actual destination type. This affects the conversion accuracy and overflow rules. The default destination type is different for each conversion type (see table below).
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 変換書式指定子
    Original:
    conversion format specifier
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
次の書式指定子が用意されています
Original:
The following format specifiers are available:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Conversion
specifier
Explanation Argument type
length modifier hh h (none) l ll j z t L
% matches literal % N/A N/A N/A N/A N/A N/A N/A N/A N/A
c matches a single character N/A N/A
char*
wchar_t*
N/A N/A N/A N/A N/A
s matches a character string (a sequence of non-whitespace characters)
[set]
文字のsetから文字の非空のシーケンスと一致.
Original:
matches a non-empty sequence of character from set of characters.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
セットの最初の文字が^であれば、しないセット内のすべての文字が一致しています。セットは]で始まる場合、または^]その後]文字もセットに含まれています.
Original:
If the first character of the set is ^, then all characters not in the set are matched. If the set begins with ] or ^] then the ] character is also included into the set.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
d
'進整数'にマッチ.
Original:
matches a decimal integer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
番号の形式はstrtol()引数の値10baseによって予想と同じです
Original:
The format of the number is the same as expected by strtol() with the value 10 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
signed char* or unsigned char*
signed short* or unsigned short*
signed int* or unsigned int*
signed long* or unsigned long*
signed long long* or unsigned long long*
N/A
i
'進整数'にマッチ.
Original:
matches a decimal integer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
番号の形式はstrtol()引数の値0baseによって予想と同じです
Original:
The format of the number is the same as expected by strtol() with the value 0 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
u
'符号なし10進整数'にマッチ.
Original:
matches a unsigned decimal integer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
番号の形式はstrtoul()引数の値0baseによって予想と同じです
Original:
The format of the number is the same as expected by strtoul() with the value 0 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
o
'8進整数'と一致.
Original:
matches an octal integer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
番号の形式はstrtol()引数の値8baseによって予想と同じです
Original:
The format of the number is the same as expected by strtol() with the value 8 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
x
'16進整数'にマッチ.
Original:
matches an hexadecimal integer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
番号の形式はstrtol()引数の値16baseによって予想と同じです
Original:
The format of the number is the same as expected by strtol() with the value 16 for the base argument
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
n
'これまでに読ん文字数'を返します。.
Original:
returns the number of characters read so far.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
入力は使用されません。割り当てカウントをインクリメントしません。指定子が定義代入抑制演算子を持っている場合、動作は未定義です
Original:
No input is consumed. Does not increment the assignment count. If the specifier has assignment-suppressing operator defined, the behavior is undefined
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
a, A
e, E
f, F
g, G
'浮動小数点数を'と一致.
Original:
matches a floating-point number.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
strtof()によって予想通り番号の形式は同じです
Original:
The format of the number is the same as expected by strtof()
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A N/A
float*
double*
N/A N/A N/A N/A
long double*
p
を定義する実装定義の文字シーケンスに一致 'ポインタを'.
Original:
matches implementation defined character sequence defining a pointer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
機能のprintf家族が%p書式指定子を使用して、同じシーケンスを生成する必要があります
Original:
printf family of functions should produce the same sequence using %p format specifier
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
N/A N/A
void**
N/A N/A N/A N/A N/A N/A
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
... -
引数を受け取る
Original:
receiving arguments
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

第1の受信引数が割り当てられていた前に読んで障害が発生した場合に正常に割り当て引数、またはEOFを受け数.
Original:
Number of receiving arguments successfully assigned, or EOF if read failure occurs before the first receiving argument was assigned.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

[編集] も参照してください

(C99)
(C99)
(C99)
stdin、ファイルストリームまたは可変引数リストを使用してbuffer
から書式付き入力を読み取ります
Original:
reads formatted input from stdin, a file stream or a buffer
using variable argument list
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(機能) [edit]
ファイルストリームから文字列を取得します
Original:
gets a character string from a file stream
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(機能) [edit]
プリントはstdout、ファイルストリームまたはバッファに出力をフォーマットします
Original:
prints formatted output to stdout, a file stream or a buffer
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(機能) [edit]
C++ documentation for scanf, fscanf, sscanf