vscanf, vfscanf, vsscanf

来自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.
scanf
fscanf
sscanf
vscanf
vfscanf
vsscanf
(C99)
(C99)
(C99)
printf
fprintf
sprintf
snprintf



(C99)
vprintf
vfprintf
vsprintf
vsnprintf



(C99)
文件定位
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 vscanf( const char *format, va_list vlist );
(1) (C99 起)
int vfscanf( FILE *stream, const char *format, va_list vlist );
(2) (C99 起)
int vsscanf( const char *buffer, const char *format, va_list vlist );
(3) (C99 起)
從各種來源中讀取數據,解釋它根據formatvlist所定義的位置,並將結果存儲到.
Original:
Reads data from the a variety of sources, interprets it according to format and stores the results into locations defined by vlist.
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 -
指針指向一個空結束的字元串讀取
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 -
指針指向一個空結束的字元串指定如何讀取輸入。
格式字元串由空白字元(格式字元串中的任何空白字元消耗所有可用的連續空格字元的輸入),非空白字元除了%(每個這樣的格式字元串的字元佔用一個相同的字元的輸入)轉換規範。每個轉換規格的格式如下:
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
匹配一個無符號十進制整數..
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
匹配八進制整數
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
匹配的「十六進制整數..
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.
格式字元串由空白字元(格式字元串中的任何空白字元消耗所有可用的連續空格字元的輸入),非空白字元除了%(每個這樣的格式字元串的字元佔用一個相同的字元的輸入)轉換規範。每個轉換規格的格式如下:
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
匹配一個無符號十進制整數..
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
匹配八進制整數
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
匹配的「十六進制整數..
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.
vlist -
可變參數列表,其中包含接收的參數
Original:
variable argument list containing the receiving arguments
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[编辑] 返回值

成功讀取的參數個數,或EOF如果發生故障.
Original:
Number of arguments successfully read, or EOF if failure occurs.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[编辑] 為例

[编辑] 另請參閱

stdin,文件流或緩衝區的讀取格式的輸入
Original:
reads formatted input from stdin, 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]
列印格式化的輸出stdout,一個文件流或buffer
使用可變參數列表
Original:
prints formatted output to stdout, 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]
C++ documentation for vscanf, vfscanf, vsscanf