int not displaying properly

I have int num set to 43, however when I print it in the serial thing it shows up as 30061. Why do that? and how can I fix it? Attached is a photo.

I have int num set to 43

No you don’t.
You need

int num = 43;

For that.

Never post a photograph of code, always post the code copied from the IDE using the copy for forum option.

I print it in the serial thing

You don’t even do that because you print ‘num’ and that means the single character represented by num, drop the single quotes.

int num(43); What does this even compile to? A function called num? Doesn't throw an error.

-jim lee

[quote[/quote]

jimLee:
int num(43); What does this even compile to? A function called num? Doesn't throw an error.

-jim lee

alternate initialisation syntax
of course all the cool kids are doing this int num{43};
now

A fight broke out on stack overflow over which was best recently, it was rubbish.

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile:

jimLee:
int num(43); What does this even compile to? A function called num? Doesn’t throw an error.

-jim lee

It matches constructor syntax.

jimLee:
int num(43); What does this even compile to? A function called num? Doesn't throw an error.

-jim lee

Function prototype maybe? Have not checked to see if it generates a warning.

As the previous post stated, it is an initialization.

It is his attempt:

Serial.println( 'num' ) ;

which has caused his unexpected result.

'um' = 0x756D = 30,061 (dec)