9 years, 7 months ago.

What size is char ?

What size is char in mbed ? Is it 8bit long ?

A site search does not show anything and I cannot find any reference to char anywhere

Thanks Kim

4 Answers

9 years, 7 months ago.

That information isn't on the mbed site because it is language specific, in c (c++) the char type is always 1 byte, and on the vast majority of devices 1 byte is 8 bits, (you will probably never encounter a device where a byte is not 8 bits)

for future reference: http://www.cplusplus.com/doc/tutorial/variables/

Accepted Answer
9 years, 7 months ago.

For further questions like this you can also do:

printf("%i", sizeof(char))

9 years, 7 months ago.

It is on the mbed site, only mbed search isn't exactly optimal :P

https://developer.mbed.org/handbook/C-Data-Types

9 years, 7 months ago.

One additional note - while the online compiler treats char as an unsigned number some c/c++ compilers default to treating char as a signed 8 bit number. If you are counting on the value being signed or unsigned for any calculations then it is best to be explicit in the declaration.

+1 for this answer

posted by Martin Kojtal 14 May 2015