is there any possibility to convert a char to a char array
example :
here is char a ='163';
char data[16];
i want to input the value of 'a' to 'data' as
data[0]='1'
data[1]='6'
data[2]='3'
data[3]='\0'
unsigned char a = 163 is valid ...
char a = '163' is not.
Look up sprintf() in your help file...
sorry, i just tried to highlight the value. thats not the code.
Quote from: manichandra on February 27, 2012, 10:18:17 PM
sorry, i just tried to highlight the value. thats not the code.
If you were using pelles C, you could look up the sprintf() function in your help file and see how to use it.
You can do this by yourself:
unsigned char a = (unsigned char)'\xa3'; //163
char data[4];
int value, pos = 0;
for (int i = 100; i > 0; i /= 10)
{
value = a / i;
a -= i * value;
data[pos++] = value + 48;
}
data[pos] = '\0';
This is very simple C code. If you do not understand this, you should take your C book and try to explore every bit of this. Just to copy the code will teach you nothing.