英寸;;什么是CHAR温度[3] =&QUOT是什么意思? [英] What is meant by char temp[3]="";?
问题描述
通常情况下,
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屋!