1. StructHandler.c:

/*
 * StructHandler.c
 *
 *  Created on: Jul 6, 2013
 *      Author: wangle
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void modifyName(struct student *p);

int main(){
    struct student{
        char name[50];
        char dep[50];
        long no;
        float score[4];
    };

typedef struct student stu_t;

struct student stu[50]={
        "wangle", "Math", 80,80,90.5,99,100,
        "xuyehui", "biological", 90,90,90,70,100,
        "mengmeng", "Math", 100,100,100,100,90
    };
    int i;
    for(i=0; i<3; i++){
        printf("%s, %s, %ld, %.2f,%.2f,%.2f,%.2f\n", stu[i].name, stu[i].dep, stu[i].no,
                stu[i].score[0], stu[i].score[1], stu[i].score[2], stu[i].score[3]);
    }

stu_t * p = stu;
    puts((*(p+1)).name);     //(1) a pointer call style.
    puts((p+1)->name);       //(2) common pointer call style. (1) and (2) is the same.

printf("%s\n", (p+2)->name);
    printf("%s\n", (*(p+2)).name);
    printf("no = %ld\n", p->no);
    void modifyName(struct student * p){
            p->no = 123456;
    }

modifyName(p);
    printf("%s\n", (p)->name);
    printf("no = %ld\n", p->no);
}

2. UnionHandler.c

/*
 * UnionHandler.c
 *
 *  Created on: Jul 6, 2013
 *      Author: wangle
 */

#include <stdio.h>
int main(){
    union unidate{
        char c;
        int i;
        long l;
        float f
    };
    union unidate x;
    x.c=65;
    printf("c=%c\n", x.c);
    x.i = 10;
    printf("i=%d\n",x.i);
    x.l = 100;
    printf("l=%ld\n", x.l);
    x.f = 90.5;
    printf("f=%.1f\n", x.f);
    printf("c=%c\n", x.c);
}

最新文章

  1. 巩固基础知识,从C# in depth开始
  2. Get Script Path in Shell
  3. Zookeeper
  4. PE查看器
  5. 【Binary Tree Level Order Traversal】cpp
  6. winform中DataGridView的数据实现导出excel
  7. Linux系统启动过程详解
  8. thinkphp 默认首页 更改
  9. CVE-2018-8120 分析
  10. [译]Ocelot - Getting Started
  11. 破解sublime的sftp
  12. Django知识总汇
  13. HAproxy 代理技术原理探究
  14. ASP.NET Web API 记录请求响应数据到日志的一个方法
  15. pythonl练习笔记——threading线程中的事件Event
  16. C#/.NET主线程与子线程之间的关系
  17. mysql my.cnf优化
  18. hiho 1318 非法二进制数 dp
  19. day2 数据结构和一些基础知识
  20. ABS(引数と同じ大きさの正の数を返す)

热门文章

  1. 在idea下开发出现404错误
  2. html生成pdf
  3. oracle聚合函数avg()注意点
  4. Migrating Your Android App from Eclipse to Android Studio
  5. apache的tomcat负载均衡和集群配置 &quot;
  6. ANSI 标准C 还定义了如下几个宏
  7. 搭建Linux C语言开发环境
  8. main()和代码块
  9. 201⑨湘潭邀请赛 Chika and Friendly Pairs(HDU6534)
  10. 力扣算法题—148sort-list