1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <stdbool.h>
  5. #define SIZE 5
  6.  
  7. typedef struct _student{
  8. char *name;
  9. int age;
  10. short id;
  11. double record;
  12. } Student;
  13.  
  14. Student *initStudent(){
  15. Student *ptrStu = (Student *)malloc(sizeof(Student));
  16. ptrStu->name = (char *)malloc(sizeof(char) * );
  17. printf("please input student info: ");
  18. printf("\nname: ");
  19. scanf("%s", ptrStu->name);
  20. printf("age: ");
  21. scanf("%d", &ptrStu->age);
  22. printf("id: ");
  23. scanf("%d", &ptrStu->id);
  24. printf("record: ");
  25. scanf("%f", &ptrStu->record);
  26.  
  27. return ptrStu;
  28. }
  29.  
  30. void displayStudent(Student *ptrStu){
  31. printf("The student %s's info: \n", ptrStu->name);
  32. printf("name: %s\n", ptrStu->name);
  33. printf("age: %d\n", ptrStu->age);
  34. printf("id: %d\n", ptrStu->id);
  35. printf("record: %f\n", ptrStu->record);
  36. printf("\n");
  37.  
  38. return;
  39. }
  40.  
  41. int main(int argc, char **argv)
  42. {
  43. Student *arrStu[SIZE];
  44. for(int i = ; i < SIZE; i++){
  45. arrStu[i] = initStudent();
  46. }
  47. for(int i = ; i < SIZE; i++){
  48. displayStudent(arrStu[i]);
  49. }
  50.  
  51. return ;
  52. }

struct init的更多相关文章

  1. C# 9.0新特性详解系列之一:只初始化设置器(init only setter)

    1.背景与动机 自C#1.0版本以来,我们要定义一个不可变数据类型的基本做法就是:先声明字段为readonly,再声明只包含get访问器的属性.例子如下: struct Point { public ...

  2. linux kernel 结构体赋值方法{转载}

    原文地址: http://www.chineselinuxuniversity.net/articles/48226.shtml 这几天看Linux的内核源码,突然看到init_pid_ns这个结构体 ...

  3. golang常见错误

    import import unuse package: error : imported and not used: "os" := = c := 1 // error non- ...

  4. 深入理解C++11

    [深入理解C++11] 1.很多 现实 的 编译器 都 支持 C99 标准 中的__ func__ 预定 义 标识符 功能, 其 基本 功能 就是 返回 所在 函数 的 名字. 编译器 会 隐式 地 ...

  5. Hyperledger Fabric链码之二

    上篇文章中我们介绍了链码的概念,本文中我们将介绍Fabric下链码的编写和测试.我们会通过一个简单例子的方式来阐述链码API的使用. 链码API     每一个链码程序都必须实现一个接口Chainco ...

  6. (转)fabric 一个链码如何调用另一个链码

    使用开发模式测试 可以使用~/hyfa/fabric-samples/chaincode-docker-devmode/启动fabric,具体过程略 用同一个链码注册2个服务 root@2ee7b51 ...

  7. 【BZOJ】2561: 最小生成树【网络流】【最小割】

    2561: 最小生成树 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 2685  Solved: 1253[Submit][Status][Discu ...

  8. 让你看不懂的swift语法

    一.Swift杂谈 Swift语法出来时间不长,网络上的各种教程已经铺天盖地,可是基本上全部的教程都是来自官方翻译. 从Swift出来到如今.每天都在学习Swift.以下给出个人感受 Swift中的非 ...

  9. HyberLedger Fabric学习(3)-chaincode学习(开发者)

    参考:http://hyperledger-fabric.readthedocs.io/en/latest/chaincode4ade.html chaincode是由go语言写的,实现了定义的接口. ...

随机推荐

  1. 【LeetCode】297. Serialize and Deserialize Binary Tree

    二叉树的序列化与反序列化. 如果使用string作为媒介来存储,传递序列化结果的话,会给反序列话带来很多不方便. 这里学会了使用 sstream 中的 输入流'istringstream' 和 输出流 ...

  2. 升级 Cocoapods 到1.2.0指定版本,降低版本及卸载

    =====================升级版本=================== CocoaPods 1.1.0+ is required to build SnapKit 3.0.0+. 在 ...

  3. Node.js(二)常用的系统模块

    http模块 第一章已经介绍了 node.js 的模块都可以传一个回调函数  回调函数支持两个参数  error , data let fs = require('fs'); fs.readFile( ...

  4. 用pycharm+django开发web项目

    pycharm是python的一个商业的集成开发工具,本人感觉做python开发还是很好用的,django是一个很流行的python web开源框架,本文就是使用pycharm+django来开发py ...

  5. Java编程思想总结笔记Chapter 3

    本章需要总结的不多,但细节的东西需要注意,有些很容易遗忘. 第三章 目录: 3.1 更简单的打印语句 3.2 使用Java操作符 3.3 优先级 3.4 赋值 3.5 算数操作符 3.6 自动递增和递 ...

  6. R Programming week1-Data Type

    Objects R has five basic or “atomic” classes of objects: character numeric (real numbers) integer co ...

  7. hibernate对象状态 的小问题

    Class classA{ List a; public void setA(List a) { this.a =a; } public List getA() { return this.a; } ...

  8. Farseer.net轻量级开源框架 中级篇:常用的扩展方法

    导航 目   录:Farseer.net轻量级开源框架 目录 上一篇:Farseer.net轻量级开源框架 中级篇: BasePage.BaseController.BaseHandler.BaseM ...

  9. webgl推荐书籍

    网址:https://www.douban.com/doulist/45940373/ webgl 来自: Pasu2017-04-17创建   2017-07-25更新   推荐 关注 2 人关注 ...

  10. 表单文件上传编码方式(enctype 属性)

    enctype 属性规定在发送到服务器之前应该如何对表单数据进行编码. 如下: <form action="upload.php" method="post&quo ...