VC environment to convert the integer type to string type (2)

Source: Internet
Author: User

In the transmission of the serial slave, it may be used to send a number, displayed as a string type of

And the previous text, "String of strings into integer" a positive and reverse, knowledge point learning will be:

#include <iostream.h>
#include <stdio.h>
#include <string.h>

void IntToStr (int m,unsigned char * str)
{int length=0;
int tmp,temp; Temp variable
Temp=m; Integer value entered on first scan
while (temp! = 0)
{
temp = TEMP/10;
length++;
}
str[length]= ' + ';
length--;

while (length >= 0)//The low position of the digits into the high position of the array
{
TMP = M%10;
str[length--] = 0x30|tmp;
m = M/10;
}

}

void Main ()
{unsigned char str[10];

int m=12345;
IntToStr (M,STR);
printf ("Input integer number:%d\n", m);
printf ("Output string is:%s\n", str);
}

//------------------------------------------------------------------------------------------------------

Integer conversions to String functions:

Verify:

VC environment to convert the integer type to string type (2)

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.