Strtol function Usage

Source: Internet
Author: User

Strtol is a C-language function that converts a string to a long integer, whose function prototype is:

Long int strtol (constcharcharintbase);

Let's look at the meaning of each parameter:

STR is the character to convert

Enptr is a pointer to the first non-convertible character position

Base base, which represents the number of conversions to a binary

Two points Note:

    • When the value of base is 0 o'clock, the default is 10-in conversion, but if the ' 0x '/' 0X ' pre-character is used with a 16-binary conversion, the ' 0 ' pre-character will be converted using the 8-in-place.
    • If endptr is not null, the character pointer that terminates the encountered non-conforming condition is passed back by endptr, or if the endptr is null, the parameter is invalid or not used.

string " 1.10.2 " ; char *c = (char*) v.c_str (); Long Ten );p rintf ("%d\n", D);p rintf ("%s\n ", c);

This code first defines a value of "1.10.2" the string c, and then call Strtol, when the D is 1, the string C becomes ". 10.2" .

Resources:

Http://c.biancheng.net/cpp/html/129.html

Strtol function Usage

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.