Conversion of numbers and characters

Source: Internet
Author: User
Today we found a very useful function: sprintf (), which is used to convert numbers into characters. Its usage is similar to our
Printf ("% d", INTA) (similar, exactly the same ).

Example:
Here

Its function prototype is:

Include < Stdio. h >

int sprintf ( char * restrict S, const Char * restrict format ,...);

at the same time, sprintf has a friendly snprintf (), which can capture the first few digits of the output. For example, output 125 only "12 ".

it is easy to convert characters into numbers. The standard library provides atoi (). Or, we recommend using strtol ().

I learned how to use C ++ for a day and found that I forgot everything I learned before.
come on.

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.