结构类型
来源:互联网 发布:淘宝客建站模板 编辑:程序博客网 时间:2024/06/18 15:22
结构体
定义有三种:
#include <stdio.h>struct date { int year; int month; int day;};//struct date today;/*// definition of structure method 2struct { int year; int month; int day;}today;*//*// definition of structure method 3struct date{ int year; int month; int day;}today;*/int main(int argc, const char *argv[]) { struct date tomorrow = {2015, 5, 13}; struct date today = {.year = 2015, .day = 12}; // Note: first defination and initialization can be work// today = {.year = 2015, .day = 12}; // it didn't work // today = tomorrow; // array can't be assignment each other today.month = 5; printf("Date of tomorrow: %d-%d-%d\n", tomorrow.year, tomorrow.month, tomorrow.day); printf("Date of today: %d-%d-%d\n", today.year, today.month, today.day); struct date *thisDay = NULL; thisDay = &today; thisDay->day++; thisDay->year++; thisDay->month++; printf("*thisDay: %d--%d--%d\n ", thisDay->day, thisDay->month, thisDay->year); return 0;}
结构,又名结构体,在其结构中可以定义多种不同数据类型的变量,
数组呢,只能定义相同数据类型的变量,一经定义后,不可改变;数组名亦是地址,但结构名不是;结构在作函数参数时要借用相关结构指针操作;
#include <stdio.h>struct point { int x; int y;};void swap(int a[], int i);void setPoint(struct point *p1);int main(){ int a[] = {3, 12,54 , 5, 6}; struct point *p = NULL; struct point mypoint = {2, 5}; p = &mypoint; setPoint(p);---------------- // ....... many codes loss return 0;}
0 0
- 结构类型
- 结构类型
- 结构类型
- 结构类型
- 结构类型和枚举类型
- Scala类型 5: 结构类型
- 结构体类型-枚举类型-联合体类型
- 枚举,结构类型
- DELPHI学习---结构类型
- 枚举和结构类型
- C#的结构类型
- 结构体类型问题
- c#结构类型
- C#数据类型-结构类型
- 结构类型用法
- C# Struct 结构类型
- Android MIME类型结构
- C#结构类型
- 【猫猫的Unity Shader之旅】之使用顶点的世界坐标
- BZOJ 4052: [Cerc2013]Magical GCD
- mvc与三层结构终极区别
- CALayer层动画详解
- 【blade的UI设计】理解前端MVC与分层思想
- 结构类型
- Matlab 7.0 安装在64位win7下解决办法
- http://www.zhihuishi.com/source/1028.html
- 关于背景裁剪与背景大小的个人总结
- Drinks Watermelon
- css3动画效果的变换个人总结
- Android中使用xml保存数据(xml文件序列化)及使用pull解析xml文件
- elf文件格式(Linux中对象文件)
- 并发编程学习记录