C language 2 to 10

Source: Internet
Author: User

There is a function in "stdlib. H": ITOA; its function is to convert the specified integer to any hexadecimal value (in the hexadecimal value range of 2 ~ 36). The prototype of this function is as follows:
Char * ITOA (INT num, char * STR, int Radix)
Where: num is your given integer;
STR is a string array, in which the converted result is stored.
Radix specifies the hexadecimal value of the conversion output. The minimum value is 2 and the maximum value is 32.

Take this question as an example:

# Include "stdlib. H" // note that you must add this sentence!

Int input;
Char output [20];

......

ITOA (input, output, 2); // because it is converted to binary, the third parameter is 2
Printf ("the binary of % d is % s", input, output );

......

In addition: 1. the ITOA () function returns the pointer pointed to by Str. Generally, no error value is returned.
2. When calling ITOA (), you must use a string of sufficient length to save the converted result.
The maximum length is 17 bytes.
3. Similar to ITOA (), there is also a function: ltoa (), which converts long integers into any
Italian notation (in hexadecimal notation 2 ~ Between 36. The usage is almost the same as that of ITOA.
The maximum length required for changing the result is 33 bytes.

 

 

Original link http://bbs.pfan.cn/post-114218.html

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.