This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

atoi and int value into unsigned char

Can i store a int into a char if result is less than 255 ?
or i need to store only the lower byte?

unsigned char mychar[10];
unsigned int intvalue;

intvalue = 1000;
intvalue = 1000 - 950;//value now is 50

mychar[0] = intvalue;//i think it is a problem trying to stores a 2 bytes var into 1 byte

Another is...
when i use atoi returns 16 bits or 8 bits?

unsigned char day;
unsigned char daytext[3];

daytext[0] = '1';
daytext[1] = '0';
daytext[2] = 0x00;

day = atoi(daytext);//i think we re going to have a problem here


Thanks a lot

0