初始化时,可随意指定初始化的元素或者元素的范围。

附gnu c 手册。

http://www.gnu.org/software/gnu-c-manual/gnu-c-manual.html

代码:

test.c

 #include <stdio.h>
static const unsigned int boot_gdt[] __attribute__((aligned())) = {
[] = 0x11223344,
[] = 0x11223344,
[ ... ] = 0x32,
[] = 0x11223344
}; typedef struct { unsigned long int pte; } pte_t; int main(void){
int len = sizeof(boot_gdt)/sizeof(int) - ;
printf("the len of boot_gdt is %d \n", len + );
for(int i = ; i <= len; i++){
printf("the %d data is 0x%x\n", i, boot_gdt[i]);
}
}

http://www.gnu.org/software/gnu-c-manual/gnu-c-manual.html#Initializing-Arrays

编译:

$ gcc -o test test.c -std=c99

运行:

$ ./test
the len of  boot_gdt is 16
the 0 data is 0x0
the 1 data is 0x11223344
the 2 data is 0x11223344
the 3 data is 0x32
the 4 data is 0x32
the 5 data is 0x32
the 6 data is 0x32
the 7 data is 0x32
the 8 data is 0x32
the 9 data is 0x32
the 10 data is 0x32
the 11 data is 0x0
the 12 data is 0x0
the 13 data is 0x0
the 14 data is 0x0
the 15 data is 0x11223344

C函数数组元素初始化的更多相关文章

  1. [fW]中断处理函数数组interrupt[]初始化

    中断处理函数数组interrupt[]初始化 2011-05-13 15:51:40 分类: LINUX 在系统初始化期间,trap_init()函数将对中断描述符表IDT进行第二次初始化(第一次只是 ...

  2. C++ Union妙用(将列表初始化用于数组元素)

    Union是个不被注意的关键字,意为联合体,这是个诡异的名字.若不是为了继承C语言,它也不会出现在C++中(虽说,union在C++中得到了扩充,完成了接近类的功能).它的作用主要是节省内存空间,在嵌 ...

  3. PHP implode() 函数 把数组元素组合为字符串

    http://www.w3school.com.cn/php/func_string_implode.asp PHP implode() 函数 PHP String 函数 实例 把数组元素组合为字符串 ...

  4. 关于C/C++中数组元素的初始化

      1.一维数组初始化 对于一维数组,其初始化有一个错误的观点是:一直以为 int a[256]={0};是把a的所有元素初始化为0,int a[256]={1};是把a所有的元素初始化为1. 数组可 ...

  5. implode() 数组元素组合函数

    定义和用法 implode() 函数把数组元素组合为一个字符串. 语法:implode(separator,array); 说明 虽然 separator 参数是可选的.但是为了向后兼容,推荐您使用使 ...

  6. 关于数组的初始化memset函数

    关于数组的初始化memset函数 其实memset复制时按bit8个8个的赋值,有兴趣的可以自己百度.

  7. 3205: 数组做函数参数--数组元素求和1--C语言

    3205: 数组做函数参数--数组元素求和1--C语言 时间限制: 1 Sec  内存限制: 128 MB提交: 178  解决: 139[提交][状态][讨论版][命题人:smallgyy] 题目描 ...

  8. java基础(环境设置,基础语法,函数数组)

    框架图 环境搭建 课程中常见dos命令: dir : 列出当前目录下的文件以及文件夹 md : 创建目录 rd : 删除目录 cd : 进入指定目录 cd.. : 退回到上一级目录 cd/ : 退回到 ...

  9. -1-1 java 基础语法 java关键字 java 注释 常量 语句 运算符 函数 数组定义

    Java语言基础组成 关键字 标识符 注释 常量和变量 运算符 语句 函数 数组 关键字 定义:被Java语言赋予了特殊含义的单词 特点:关键字中所有字母都为小写 用于定义数据类型的关键字 class ...

随机推荐

  1. HTML5新元素

    <figure> 标签规定独立的流内容(图像.图表.照片.代码等等). <figure> 元素的内容应该与主内容相关,同时元素的位置相对于主内容是独立的.如果被删除,则不应对文 ...

  2. 关于 java.io.IOException: open failed: EACCES (Permission denied)

    今天解决了一个问题,不得不来和大家分享.就是关于 java.io.IOException: open failed: EACCES (Permission denied)的问题,网上也有很多人把这个问 ...

  3. 【Chromium中文文档】Chrome/Chromium沙箱 - 安全架构设计

    沙箱 转载请注明出处:https://ahangchen.gitbooks.io/chromium_doc_zh/content/zh//General_Architecture/Sandbox.ht ...

  4. 【git】error: Your local changes to the following files

    今天在服务器上git pull是出现以下错误: error: Your local changes to the following files would be overwritten by mer ...

  5. 同步Flex Chart的数据提示

    原文 http://www.riafan.com/sync-datatips-for-flex-chart/ 图表数据提示的同步不仅包含单个图表内多个系列的数据提示的同步,也包含多个图表的数据提示的同 ...

  6. 【OpenGL游戏开发之二】OpenGL常用API

    OpenGL常用API 开发基于OpenGL的应用程序,必须先了解OpenGL的库函数.它采用C语言风格,提供大量的函数来进行图形的处理和显示.OpenGL库函数的命名方式非常有规律.所有OpenGL ...

  7. AndroidUI 布局动画-为布局添加动画

    除了可以为视图添加动画以外,还可以为视图的布局添加动画: <RelativeLayout xmlns:android="http://schemas.android.com/apk/r ...

  8. Xcode7.3.1真机调试ios10

    如果自己的ios测试机不小心升级到比Xcode更高的ios系统, 那么这时候是无法使用真机来进行调试的. 但是我们可以通过拷贝与测试机一样版本的系统来解决这个问题. 去下载一个Xcode8,然后安装, ...

  9. 得到当前网址的域名 ASP.NET

    HttpContext.Current.Request.Url.Host.ToString(); http://"是协议名 "www.test.com"是域名 " ...

  10. struts2整合json要注意的问题

    昨天struts2整合json,一直出错: There is no Action mapped for namespace / and action name ... HTTP Status 404 ...