首页 > 技术文章 > 指针-结构体

liangjinjie 2017-05-03 16:55 原文

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 
 4 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
 5  
 6 int main(int argc, char *argv[]) {
 7     //调用结构体函数 
 8      jiegouti();
 9     return 0;
10 }
11 //结构体 
12 //声明一个结构体函数 
13 void jiegouti(){
14     //定义结构体变量    
15     struct student{
16         int age;//年龄 
17         char* name;//姓名 
18     };
19     //给结构 体初始化 赋值 
20     struct student ljj={
21         20,"梁锦杰"
22     };
23     //打印结构体内容 
24     printf("%d\n",ljj.age);
25     printf("%s\n",ljj.name);
26 } 

推荐阅读