Custom integer to string ltos

Source: Internet
Author: User


// DEST string stores the data base to be converted by VAL: 10 in hexadecimal notation and 16 in hexadecimal notation

Char * ltos (char * DEST, ulong Val, ulong Base)

{

Char TMP [16] = {0 };

Char * RTN = DEST;

Char pH [11] = {"0x00000000"}; // This is based on your needs

Int I = 0, j = 0;

Const char small_digits [] = "0123456789 abcdef ";


If (val = 0)

{

TMP [I ++] = '0 ';

}

Else

{

While (Val! = 0)

{

TMP [I ++] = small_digits [Val % base];

Val/= base;

}

}

If (base = 16)

{

Memcpy (DEST, pH, 11-I );

J + = (10-I );

}


While (Dest [J ++] = TMP [-- I])! = '\ 0' & I );

Return RTN;

}


Custom integer to string ltos

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.