SSCANF definition and usage and analysis _php tutorials

Source: Internet
Author: User
SSCANF definition and usage and analysis
The sscanf () function parses input from a string according to the specified format.

If only two parameters are passed to the function, the data is returned as an array. Otherwise, if additional parameters are passed, the parsed data is stored in these parameters. If the number of delimiters is greater than the number of variables that contain them, an error occurs. However, if the delimiter is less than the variable, the extra variable contains null.

Grammar
SSCANF (string,format,arg1,arg2,arg++) parameter description
string is required. Specifies the string to read.
Format required. Specifies the format to use.
Arg1 is optional. The first variable that stores the data.
Arg2 is optional. A second variable that stores data.
arg++ is optional. A third to fourth variable that stores data. And so on

Description
The parameters format is the converted format, starting with the percent sign ("%") to the end of the converted character. The following possible format values are:

Percent-return percentage symbol
%b-Binary number
%c-Characters in accordance with ASCII values
%d-Signed decimal number
%e-Sustainable counting method (e.g. 1.5e+3)
%u-Unsigned decimal number
%f-Floating point (Local settings Aware)
%f-Floating point number (not local settings aware)
%o-Eight binary number
%s-String
%x-16 binary number (lowercase letters)
%x-16 decimal digits (uppercase letters)
Example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.