-

差分

移動先: 案内検索

Functions HI-TECH C SCANF

46 バイト追加, 2018年1月5日 (金) 09:59
編集の要約なし
==詳細==
<strong>Scanf</strong>()はstdinストリームからの整形された入力を"de-editing")します??一般的にストリームや文字列に対して使用可能な類似した関数があります。<strong>vscanf</strong>()は類似した関数ですが、連続した引数ではなく、引数リストへのポインタを取ります。このポインタは<strong>va_start</strong>()で初期化されるべきです。入力変換はfmt文字列で処理されます。一般的に整形された文字列は入力内の文字にマッチしなければいけません。しかし、整形文字列内のスペース文字は、入力内のゼロもしくはスペース、タブやnewlineの"ホワイトスペース文字"にマッチします。    A conversion specification takes theform of the character にマッチします。変換指定は%, optionally followed by anassignment suppression character 文字を使った形式を取り、オプションで代入抑制文字('*'), optionally followed by a numerical maximum field width, followed by aconversion specification character. Each conversionspecification, unless it incorporates the assignmentsuppression character, will assign a value to the variable pointed at by the next argument. Thus if there aretwo conversion specifications in the fmt string, thereshould be two additional pointer arguments. Theconversion characters are as follows:、最大幅の数値、変換指定文字などが後に続きます。どの変換指定も代入抑制文字と連携することなく、次の引数によって変数の位置が指定されて、値が割り当てられます。fmt文字列による二つの変換指定があるときは2つの追加の位置指定引数が必要です。変換文字列は以下の通りです。
;o x d
:Skip white spaceホワイトスペースをスキップし、8, then convert a number in base 8, 16 or 10 radix respectively. If a field width was supplied, take at most that many characters from the input. A leading minus sign will be recognized.10進数の数をそれぞれ変換します。幅指定が供給されると、入力からできるだけ多くの文字を取ります。最初のマイナス符号は認識されます。
;f
:Skip white space, then convert a floating number in either conventional or scientific notation. The field width applies as above.ホワイトスペースをスキップし、浮動小数点数を伝統的?、科学的表記で変換します。幅指定に関しては上記と同様に適用されます。
;s
:Skip white space, then copy a maximal length sequence of non-white-space characters. The pointer argument must be a pointer to char. The field width will limit the number of characters copied. The resultant string will be null-terminated.ホワイトスペースをスキップし、ホワイトスペース文字以外の文字の連続を最大限の長さでコピーします。ポインタ引数はcharへのポインタである必要があります。幅指定に関してはコピーされた文字数に限られます。結果的に生じた文字列はヌル終端になります。
;c
:Copy the next character from the input. The pointer argument is assumed to be a pointer to char. If a field width is specified, then copy that many characters. This differs from the s format in that white space does not terminate the character sequence.入力から次の文字をコピーします。ポインタ引数はcharへのポインタであると仮定されます。幅指定があると、多くの文字がコピーされます。ホワイトスペースは文字列の連続を終端しない点でs形式とは違います。
The conversion characters o変換文字であるo, x, u, d and f may be preceded by an l to indicate that the corresponding pointer argument is a pointer to long or double as appropriate. A preceding h will indicate that the pointer argument is a pointer to short rather than int., fは、対応する引数ポインタがlongかdoubleか適切に示すlに先行します。先行するhはポインタ引数がintではなく、shortであることを示します。
<strong>Scanf</strong>()は変換が成功した数を返します。

案内メニュー