什么是一个未初始化数组一个字符的默认值,在C? [英] What is the default value of a char in an uninitialized array, in C?

查看:150
本文介绍了什么是一个未初始化数组一个字符的默认值,在C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于以下声明:

字符INPUTBUFFER [12];

什么是阵列内是char的默认值?
我想知道这一点,因为如果在任何时候,我要清除的数组中的位置,我需要知道什么价值给它。

What is the default value of either char within the array? I'm interested in knowing this because if at any time I want to clear a position in the array, I need to know what value to give it.

推荐答案

数组元素具有不确定的值,除非它是在文件范围内定义或阵列具有静态存储类说明则数组元素被初始化为 0

The array elements have indeterminate value except if the array it is defined at file-scope or have static storage-class specifier then the array elements are initialized to 0.

 #include <stdio.h>

 char inputBuffer1[12];          // elements initialized to 0
 static char inputBuffer2[12];   // elements initialized to 0

 void foo(void)
 {
     char inputBuffer3[12];         // elements have indeterminate value!
     static char inputBuffer4[12];  // elements initialized to 0
 }

这篇关于什么是一个未初始化数组一个字符的默认值,在C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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