英寸;;什么是CHAR温度[3] =&QUOT是什么意思? [英] What is meant by char temp[3]="";?

查看:199
本文介绍了英寸;;什么是CHAR温度[3] =&QUOT是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常情况下,

char example[5]="cat";

如果您(只是一个双引号无空格)初始化什么呢?结果
会有什么初始化之后的字符数组中的元素?

What if you initialize it with "" (just a double quotes without spaces)?
What will be the elements in the character array after initialization?

推荐答案

声明

char    temp[3] = "";

是一样的。

char    temp[3] = {0};
                  // `\0` ascii value is 0

记住保持与 0 初始化一半初始化数组的元素。

remember remaining elements of half initialized array initialized with 0.

点:字符临时[3] =容易到<大骨节病>键入(指写作),所以其preferable。

Point :char temp[3] = "" is easy to type(means writing), so its preferable.

看甚至可以与该声明比较字符临时[3] = {'\\ 0'}; (它需要更多的字符为<大骨节病>键入 ),而在字符临时[3] =; 很简单(甚至没有类型不匹配 - INT /字符)。

Look even compare it with this declaration char temp[3] = {'\0'}; (it need more chars to type) Whereas in char temp[3] = ""; is simple (even no type mismatch - int/char).

这篇关于英寸;;什么是CHAR温度[3] =&QUOT是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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