c语言 malloc小案例1
2015-08-18 00:06
579 查看
#include<stdio.h>
#include<malloc.h>
struct Student * CreateStudent();
ShowStudentInfo(struct Student * stu);
struct Student{
int sid;
int age;
};
main(void){
struct Student * xiaoMing = CreateStudent();
ShowStudentInfo(xiaoMing);
}
struct Student * CreateStudent(){
struct Student * stu = (struct Student *) malloc(sizeof(struct Student) );
stu->age = 100;
stu->sid = 01;
return stu;
}
ShowStudentInfo(struct Student * stu){
printf("sid = %d,age = %d",stu->sid,stu->age);
}
#include<malloc.h>
struct Student * CreateStudent();
ShowStudentInfo(struct Student * stu);
struct Student{
int sid;
int age;
};
main(void){
struct Student * xiaoMing = CreateStudent();
ShowStudentInfo(xiaoMing);
}
struct Student * CreateStudent(){
struct Student * stu = (struct Student *) malloc(sizeof(struct Student) );
stu->age = 100;
stu->sid = 01;
return stu;
}
ShowStudentInfo(struct Student * stu){
printf("sid = %d,age = %d",stu->sid,stu->age);
}
相关文章推荐
- google C++编程风格指南之头文件的包含顺序
- google C++编程风格指南之头文件的包含顺序
- C++零基础教程,游戏开发入门
- C/C++获取本地时间常见方法
- C/C++获取本地时间常见方法
- 【C++】sprintf的用法详解 (打印成各种格式的字符串)
- HDOJ-1874-畅通工程续(最短路)
- C++中public、protected及private区别
- Effective C++ 条款3 尽可能用const
- C++的struct和union
- C++的struct和union
- c语言 typedef的用法
- printf中的使用(c语言)
- C++ 输出缓冲区的管理
- C++ 输出缓冲区的管理
- 逆波兰表达式实现计算器(附c++代码)
- C++中变量的作用域与生命周期
- C++拷贝构造函数详解
- c++类的初创建(复数类)
- C++对象模型——临时性对象 (第六章)