2015-03-24 11:03 PM
Thank for your look and help.
I want to send a string ''&sharp1250♯'', and the 1250 is the sensor value. So I do some try. uint16_t ch=1250; uint16_t Value[4]; char str[10] = ''♯''; Value[0] = (ch /1000 )+48 ; // divide number by 1000 ch = (ch % 1000) ; // take remainder number of 1000 Value[1] = (ch / 100 )+48; // divide this now by 100 ch = (ch % 100 ) ;// take remainder of 100 Value[2] = (ch / 10)+48 ; // divide remainder by 10 Value[3] = (ch % 10 ) +48; // load remainder of final Dimension into unit variable strcat(str,Value); strcat(str,''♯''); However, when I look at debug mode, it give me the result str[0]='♯' str[1]='1' str[2]='2' str[3]='5' str[4]='0' str[5]=2 str[6]='♯' there is a non need 2 appear in str[5] but when I change strcat(str,Value) to strcat(str,''1250'') there are no matter. May I ask what is the problem of doing this? #string2015-03-25 11:02 AM
2015-03-25 11:52 AM
But the simplest way to do this is
sprintf (str, ''#%04d#'', ch) ;
with
all
printf formatting options
you
can experiment
online
with
the
C compiler
that you find
here http://www.tutorialspoint.com/compile_c_online.php2015-03-25 11:49 PM