"Algorithms and data Structures" _16_ small algorithm _inttostr: converting integer data to Strings

Source: Internet
Author: User

1 /*2 inttostr: Converting integer data to Strings3 */4 5#include <stdio.h>6 7 8 voidINT_TO_STR (ConstUnsignedLong intI_number,Char*str);9 Ten intMainintargcChar*argv[]) One { AUnsignedLong inti_test; -    Charstr[ -]; -  thei_test=1234567; - int_to_str (I_TEST,STR); -     - puts (str); +  -    return 0; + } A  at /* - function Function: - converts an integer number to a string consisting of 0-9 characters - For example: - will 123--> "123" - function Prototypes: in void Int_to_str (const unsigned long int i_number, char *str) - function Parameters: to const unsigned long int i_number: integer value to convert + char *str: Used to store converted strings - Exception: the */ *  $ voidINT_TO_STR (ConstUnsignedLong intI_number,Char*str)Panax Notoginseng { -UnsignedLong inti_temp; the     Char*P_char_head; +     Char*p_char_temp; A     Charchar_temp; the      +i_temp=I_number; -P_char_head=str; $p_char_temp=str; $  -      while(Ten<i_temp) -     { the* (p_char_temp++) = (i_temp%Ten) +'0'; -I_temp/=Ten;Wuyi     } the* (p_char_temp) =i_temp +'0'; -* (++p_char_temp) =' /'; Wu--p_char_temp; -  About      while(P_char_temp >p_char_head) $     { -char_temp=*(p_char_temp); -* (p_char_temp--) =*(p_char_head); -* (p_char_head++) =char_temp; A     } +      the}

"Algorithms and data Structures" _16_ small algorithm _inttostr: converting integer data to Strings

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.