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语言写的,实现了定义的接口. ...
随机推荐
- vijos P1412多人背包 DP的前k优解
https://vijos.org/p/1412 把dp设成,dp[i][v][k]表示在前i项中,拥有v这个背包,的第k大解是什么. 那么dp[i][v][1...k]就是在dp[i - 1][v] ...
- 把sed当作命令解释器使用
[root@sishen ~]# vim script.sed #!/bin/sed -f #交换第一列和第二列 s/\([^,]*\),\([^,]*\),\(.*\).*/\2,\1, \3/g ...
- hbase源码分析:ERROR: Table already exists问题诊断
问题描述: 重新安装了测试环境的hadoop,所以之前hbase所建的表数据都丢失了,但是zookeeper没有动.在hbase shell中list的时候,看不到之前建的表,但是create tes ...
- sdut2784&cf 126b Good Luck!(next数组)
链接 next数组的巧妙应用 学弟出给学弟的学弟的题.. 求最长的 是前缀也是后缀同时也是中缀的串 next的数组求的就是最长的前后缀 但是却不能求得中缀 所以这里 就把尾部去掉之后再求 这样就可 ...
- C# Equals的重写
using System; using System.Collections.Generic; using System.Text; namespace Equal { using Syste ...
- Redis相关问题收集
问题一.强制关闭Redis快照导致不能持久化 MISCONF Redis is configured to save RDB snapshots, but is currently not able ...
- 免费公共DNS服务器IP地址大全(2017年6月24日)
收集全球各个常用公共DNS服务器 IP地址,欢迎各位朋友评论补充! 国内常用公共DNS 114 DNS: (114.114.114.114: 114.114.115.115) 114DNS安全版 ...
- CentOS 7 安装Oracle VirtualBox
1. 下载VirtualBox的repo文件: 登陆 https://www.virtualbox.org/wiki/Linux_Downloads 在网页的最下端的repo链接上右键下载,或者wge ...
- Adobe Dreamweaver CC 2014 代码颜色目录 dw
他的颜色代码配置文件,不在安装目录下,这让我好找啊~ C:\Users\Administrator\AppData\Roaming\Adobe\Dreamweaver CC 2014\zh_CN\Co ...
- Axis1.4框架 实现webservice服务器和客户端
一:软件环境 win7旗舰版, Eclipse,JDK1.6,tomcat6.0,Axis1.4的包. 至于Axis1.4包网上可以下载,如果是在找不到可以留言给我. 二:摘要 将解压后的 axis- ...