struct init
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#define SIZE 5 typedef struct _student{
char *name;
int age;
short id;
double record;
} Student; Student *initStudent(){
Student *ptrStu = (Student *)malloc(sizeof(Student));
ptrStu->name = (char *)malloc(sizeof(char) * );
printf("please input student info: ");
printf("\nname: ");
scanf("%s", ptrStu->name);
printf("age: ");
scanf("%d", &ptrStu->age);
printf("id: ");
scanf("%d", &ptrStu->id);
printf("record: ");
scanf("%f", &ptrStu->record); return ptrStu;
} void displayStudent(Student *ptrStu){
printf("The student %s's info: \n", ptrStu->name);
printf("name: %s\n", ptrStu->name);
printf("age: %d\n", ptrStu->age);
printf("id: %d\n", ptrStu->id);
printf("record: %f\n", ptrStu->record);
printf("\n"); return;
} int main(int argc, char **argv)
{
Student *arrStu[SIZE];
for(int i = ; i < SIZE; i++){
arrStu[i] = initStudent();
}
for(int i = ; i < SIZE; i++){
displayStudent(arrStu[i]);
} return ;
}
struct init的更多相关文章
- C# 9.0新特性详解系列之一:只初始化设置器(init only setter)
1.背景与动机 自C#1.0版本以来,我们要定义一个不可变数据类型的基本做法就是:先声明字段为readonly,再声明只包含get访问器的属性.例子如下: struct Point { public ...
- linux kernel 结构体赋值方法{转载}
原文地址: http://www.chineselinuxuniversity.net/articles/48226.shtml 这几天看Linux的内核源码,突然看到init_pid_ns这个结构体 ...
- golang常见错误
import import unuse package: error : imported and not used: "os" := = c := 1 // error non- ...
- 深入理解C++11
[深入理解C++11] 1.很多 现实 的 编译器 都 支持 C99 标准 中的__ func__ 预定 义 标识符 功能, 其 基本 功能 就是 返回 所在 函数 的 名字. 编译器 会 隐式 地 ...
- Hyperledger Fabric链码之二
上篇文章中我们介绍了链码的概念,本文中我们将介绍Fabric下链码的编写和测试.我们会通过一个简单例子的方式来阐述链码API的使用. 链码API 每一个链码程序都必须实现一个接口Chainco ...
- (转)fabric 一个链码如何调用另一个链码
使用开发模式测试 可以使用~/hyfa/fabric-samples/chaincode-docker-devmode/启动fabric,具体过程略 用同一个链码注册2个服务 root@2ee7b51 ...
- 【BZOJ】2561: 最小生成树【网络流】【最小割】
2561: 最小生成树 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 2685 Solved: 1253[Submit][Status][Discu ...
- 让你看不懂的swift语法
一.Swift杂谈 Swift语法出来时间不长,网络上的各种教程已经铺天盖地,可是基本上全部的教程都是来自官方翻译. 从Swift出来到如今.每天都在学习Swift.以下给出个人感受 Swift中的非 ...
- HyberLedger Fabric学习(3)-chaincode学习(开发者)
参考:http://hyperledger-fabric.readthedocs.io/en/latest/chaincode4ade.html chaincode是由go语言写的,实现了定义的接口. ...
随机推荐
- 简单工厂模式及php实现
简单工厂模式(Simple Factory Pattern): 又称为静态工厂方法(Static Factory Method)模式,它属于类创建型模式.在简单工厂模式中,可以根据参数的不同返回不同类 ...
- 将call/apply方法应用于其他对象上的几种方法
在处理类数组中,发现了两种将数组方法应用于类数组的方法,现将call/apply的常用方式总结一下. 一.当做函数调用 function print_vars(var1,var2){ console. ...
- Unity笔记(4)自学第四、五天
主要是移动脚本和2个技能的脚本编写. 首先是移动的脚本: using System.Collections; using System.Collections.Generic; using Unity ...
- Win10 1803更新UWP无法安装的解决办法|错误代码0x80073D0D
升级Win10 1803后,出现了之前安装的UWP.应用无法更新,再此安装失败的现象. 应用商店错误代码为:0x80073D0D,尝试卸载重装商店,清除应用缓存也无法解决. 最终解决办法: 下载Eve ...
- scala.的Enumeration枚举示例(转)
简介 在scala中没有枚举类型,但在标准类库中提供了Enumeration类来产出枚举.扩展Enumeration类后,调用value方法类初始化枚举中的可能值. 内部类value实际上是一个抽象类 ...
- hibernate 批量插入数据
如题,有两种方法 1)使用FLUSH 2)使用JDBC 分别来解释: 1)hibernate在进行数据库操作的时候,都要有事务支持的.可能你曾遇到过,没有加事务,程序会报错的情况. 而事务每次提交的时 ...
- .net mvc 运行监控和错误捕捉
方法类 /// <summary> /// 运行监控类 /// </summary> [AttributeUsage(AttributeTargets.Class | Attr ...
- Method Dispatch in Protocol Extensions
We learned in the Protocol-Oriented Programming session at WWDC 2015 that Swift uses two different d ...
- Debug:This kind of launch is configured to openthe debug perspective when it解决办法
http://blog.sina.com.cn/s/blog_7ca3aa020100zlha.html 启动tomcat时,myeclipse报错: This kind of launch is c ...
- 面试之Spring
一.IoC IoC(Inversion of Control):控制反转(是把传统上由程序代码直接操控的对象的生成交给了容器来实现, 通过容器来实现对象组件的装配和管理.所谓"控制反转&qu ...