IOS uses Strtoul to transform the system

Source: Internet
Author: User
Role:
Converts a string to decimal by using the function strtoul (const char *, char * *, int) in the corresponding binary format
    char* p;//Position string conversion termination
    unsigned long s = Strtoul ("FFt6", &p,);
    NSLog (@ "%lu", s);
    NSLog (@ "%c", *p);
Explain:
The first parameter is the target string that needs to be converted, the second parameter is the position that is terminated during the conversion, the
third parameter is the feed corresponding to the target string, and the 0 indicates automatic detection of the conversion format,
example: The above code ' FFT6 ' is the target string, FF is 16, The third parameter is set to 16.
Execution results:
2016-03-22 17:44:52.557 demoo[12381:434989] 255
2016-03-22 17:44:52.557 demoo[12381:434989] t
The third parameter in the execution result is the first character that cannot be converted: ' t ', and hexadecimal ' FF ' corresponds to the decimal;
Top: This method is typically used to convert other strings into decimal numbers.
Related Article

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.