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语言写的,实现了定义的接口. ...
随机推荐
- 【LeetCode】297. Serialize and Deserialize Binary Tree
二叉树的序列化与反序列化. 如果使用string作为媒介来存储,传递序列化结果的话,会给反序列话带来很多不方便. 这里学会了使用 sstream 中的 输入流'istringstream' 和 输出流 ...
- 升级 Cocoapods 到1.2.0指定版本,降低版本及卸载
=====================升级版本=================== CocoaPods 1.1.0+ is required to build SnapKit 3.0.0+. 在 ...
- Node.js(二)常用的系统模块
http模块 第一章已经介绍了 node.js 的模块都可以传一个回调函数 回调函数支持两个参数 error , data let fs = require('fs'); fs.readFile( ...
- 用pycharm+django开发web项目
pycharm是python的一个商业的集成开发工具,本人感觉做python开发还是很好用的,django是一个很流行的python web开源框架,本文就是使用pycharm+django来开发py ...
- Java编程思想总结笔记Chapter 3
本章需要总结的不多,但细节的东西需要注意,有些很容易遗忘. 第三章 目录: 3.1 更简单的打印语句 3.2 使用Java操作符 3.3 优先级 3.4 赋值 3.5 算数操作符 3.6 自动递增和递 ...
- R Programming week1-Data Type
Objects R has five basic or “atomic” classes of objects: character numeric (real numbers) integer co ...
- hibernate对象状态 的小问题
Class classA{ List a; public void setA(List a) { this.a =a; } public List getA() { return this.a; } ...
- Farseer.net轻量级开源框架 中级篇:常用的扩展方法
导航 目 录:Farseer.net轻量级开源框架 目录 上一篇:Farseer.net轻量级开源框架 中级篇: BasePage.BaseController.BaseHandler.BaseM ...
- webgl推荐书籍
网址:https://www.douban.com/doulist/45940373/ webgl 来自: Pasu2017-04-17创建 2017-07-25更新 推荐 关注 2 人关注 ...
- 表单文件上传编码方式(enctype 属性)
enctype 属性规定在发送到服务器之前应该如何对表单数据进行编码. 如下: <form action="upload.php" method="post&quo ...