开发者

Setting Char variables

开发者 https://www.devze.com 2023-04-12 01:48 出处:网络
For a char variable would i also set it to 0 as i would set and int or a float or any other variable?

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开发者_如何学C since

int test = 0

would be like that?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号