Rules for Initializing Strutures in C

原创 2012年03月30日 18:58:37

       以前没怎么注意这个问题,因为学习c语言的时候不是很用心,基本是混日子,根本没有意识的在c语言里,struct有多么的重要。现在我学了c++,java等,然后回过来看c,就发觉struct相当重要,很多时候就承担了在面向对象里的类的功能,只不过它没有继承,没有多态,没有重载。

      今天看了一些,发现有些规则相当重要:

There is a few rules to keep in mind while initializing structure variable at compile-time:

1.We cannot initialize individual members inside the structure template;

2.The order of values enclosed in braces must match the order of menmbers in the structure definition;

3.It is permitted to have a partial initialization. We can initialize only the first few members and leave the remaining blank.The uninitialized members should be only at the end of the list.

4.The uninitialized members will be assigned default values as follows:

         1).Zero for integer and floating point numbers.

         2).'\0'for characters and strings.



版权声明:本文为博主原创文章,未经博主允许不得转载。 举报

相关文章推荐

UDEV SCSI Rules Configuration for ASM in Oracle Linux 5 and 6

http://www.oracle-base.com/articles/linux/udev-scsi-rules-configuration-in-oracle-linux-5-and-6.php ...

UDEV SCSI Rules Configuration for ASM in Oracle Linux 5, 6 and 7

从oracle-base中看到这篇文章,写的比较详细,分享一下For Oracle Automatic Storage Manager (ASM) to use disks, it needs to ...

我是如何成为一名python大咖的?

人生苦短,都说必须python,那么我分享下我是如何从小白成为Python资深开发者的吧。2014年我大学刚毕业..

tomcat启动不了——Error initializing endpoint——java.net.BindException: Address already in use: JVM_Bind <n

信息: The APR based Apache Tomcat Native library which allows optimal performance in production enviro...

HowTo compile native C codes to a library for iOS development in Xcode – take Mosquitto as an exampl

HowTo compile native C codes to a library for iOS development in Xcode – take Mosquitto as an exampl...

Strategies for Using C++ in Objective-C Projects (and vice versa)

Update (May 2012): while nothing in this article is incorrect, there have been some changes to Objec...

The different between #define and const for a constant in C

这应该算一个经常争论的话题,而且往往没有个结果。 虽然他们在使用中感觉“差不多”,但是他们在实现上有什么区别? 请看下面的代码: 3:    #define T 13 /*用#define定义的...

Effective Objective-C(第47-52条)系统架构,foundation、for-in、NSTimer

第47条:熟悉系统框架         若是不了解系统架构所提供的内容,那么就可能会把其中已经实现的东西再写一遍。将一系列代码封装为动态库(dynamic library),并在其中放入描述其接口的头...

《Effective Objective-C 2.0》—(第47-52条)—系统架构,foundation、快速遍历for-in、NSTimer

collection使用无缝桥接 快速遍历for-in的使用 谨慎NSTimer的循环引用
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)