soniccool
soniccool

Reputation: 6058

Setting Char variables

For a char variable would i also set it to 0 as i would set and int or a float or any other variable?

Such as

char test = 0 

would it be like that since

int test = 0

would be like that?

Upvotes: 0

Views: 911

Answers (2)

Anidhya Ahuja
Anidhya Ahuja

Reputation: 873

You can always use type conversions in c++, so even if you write int test = 0 you can access its ascii by converting it into char, this goes without saying for chars

Upvotes: 0

Mysticial
Mysticial

Reputation: 471229

Which do you want? The character '0', or the ascii 0?

If you want to set it to the character '0', then you need:

char test = '0';

If you want the ascii value 0, then it's fine the way it is.

Upvotes: 3

Related Questions