(char)0在C ++中是什么意思? [英] What does (char)0 mean in c++?

查看:386
本文介绍了(char)0在C ++中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(char)0 是什么意思。

例如,这是什么意思? p>

For example what does this mean?

array[1] = (char)0;


推荐答案

这是C样式的强制转换。也就是说,它将 0 (这是类型为 int 的文字)转换为 char \0 字符)。只需使用'\0'文字就可以完全避免这种转换。

It's a C-style cast. That is, it converts 0 (which is a literal of type int) to char (the \0 character). That cast could have been avoided entirely by simply using the '\0' literal.

这篇关于(char)0在C ++中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆