variable declaration just unsigned and no data type

Hi,

In native c, if a variable is declared as just static unsigned value without a type, can it contain both numbers and letters i.e. for hex values?

Thanks

It's an 'unsigned int'.

ultrasonicbananna: Hi,

In native c, if a variable is declared as just static unsigned value without a type, can it contain both numbers and letters i.e. for hex values?

Thanks

It can store whatever you like, just as long as what you like occupies no more than sixteen bits.

ultrasonicbananna: Hi,

In native c, if a variable is declared as just static unsigned value without a type, can it contain both numbers and letters i.e. for hex values?

Thanks

There are no untyped variables in C. You get a default type as OldSteve said.

I'm just wondering about this:-

contain both numbers and letters i.e. for hex values?

Maybe I'm misunderstanding you, but.... When storing a hex value, a combination of letters and numbers isn't stored. ie When you set a variable to 0x05 (hex), exactly the same thing is stored as if you set it to 5 (decimal). The "x" in the hex value isn't placed into the variable. It's just a way of representing it for humans. Assuming an 8-bit variable, in both cases, the variable will hold 0b00000101.

OldSteve is right. It all comes down to how YOU interpret the value. Although the Arduino IDE (/underneath code) has some preferences on how to interpret a variable (for example, a char as a variable with a ASCII representation of a character) it's not fixed.

For example, this will work just fine

unsigned int myInt = 'm';
Serial.print( (char)myInt );

I casted the unsigned int to a char because the default action of calling Serial.print() when using a int is to print the numeric value. The default action of calling Serial.print() with a char is to print the ASCII representation of that variable.