C/C++ 结构体 指针 简单输入输出
#include <stdio.h>
#include <stdlib.h> struct student{
int num;
char str[];
double dec;
}; int main(){
int n;
struct student *stu; scanf("%d", &n);
stu = (struct student *)malloc(n * sizeof(struct student)); for(int i = ; i < n; ++i){
scanf("%d%s%lf", &stu[i].num, stu[i].str, &stu[i].dec);
} printf("%d\n", n);
for(int i = ; i < n; ++i){
printf("%d %s %lf\n", stu[i].num, stu[i].str, stu[i].dec);
} free(stu);
return ;
}
/*
3
20 字符串0 20.02
21 字符串1 21.12
22 字符串2 22.22
*/
C/C++ 结构体 指针 简单输入输出的更多相关文章
- C/C++ 结构体 数组 简单输入输出
#include <stdio.h> #include <stdlib.h> struct student{ int num; ]; double dec; }; int ma ...
- 【C语言入门教程】7.3 结构体指针的定义和引用
C 语言中指针的操作非常灵活,它也能指向结构体变量对结构体变量进行操作.在学习结构指针之前,需要再次加深对指针的认识.声明指针变量时所使用的数据类型修饰符实际上的作用是定义指针访问内存的范围,如果指针 ...
- c语言中的结构体指针类型的cast
1.我们在c语言中会经常碰到强制类型转换. 在这,我介绍一种结构pointer类型转换,但是有前提(有点类似于c++中的继承中的子父对象的cast). 简单的介绍一下: 首先我们要知道一个结构的指针, ...
- Android JNI编程(六)——C语言函数指针、Unition联合体、枚举、Typedef别名、结构体、结构体指针
版权声明:本文出自阿钟的博客,转载请注明出处:http://blog.csdn.net/a_zhon/. 目录(?)[+] 一:函数指针 1.函数指针顾名思义就是定义一个指针变量指向一个函数,和一级指 ...
- 解惑结构体与结构体指针(struct与typedef struct在数据结构的第一道坎)
/* 数据结构解惑01 在数据结构中会看到 typedef struct QNode { QElemType data; //数据域 struct QNode *next; //指针域 }QNode ...
- C与指针(结构体指针,函数指针,数组指针,指针数组)定义与使用
类型 普通指针 指针数组(非指针类型) 数组指针 结构体指针 函数指针 二重指针 定义方式 int *p; int *p[5]; int (*p)[5]; int a[3][5]; struct{.. ...
- ctypes 操作 python 与 c++ dll 互传结构体指针
CMakeLists.txt # project(工程名) project(blog-3123958139-1) # add_library(链接库名称 SHARED 链接库代码) add_libra ...
- python 传递结构体指针到 c++ dll
CMakeLists.txt # project(工程名) project(xxx) # add_library(链接库名称 SHARED 链接库代码) add_library(xxx SHARED ...
- Delphi 中的结构体与结构体指针
好多程序都给结构体变量设定了一个结构体指针 例如: PAbc = ^TAbc; TAbc = record a: string[10]; b: string[5]; c: string[1]; end ...
随机推荐
- Codeforces Round #353 (Div. 2)
数学 A - Infinite Sequence 等差数列,公差是0的时候特判 #include <bits/stdc++.h> typedef long long ll; const i ...
- addview的使用
之前,使用addview(控件1)的时候 之前是需要给控件1添加一个位置设定,比如是设定在右侧 使用了addrule 但是我想到的是,如果是给一个view 的 后面延长,把该控件放在上面呢?
- CodeForces460B. Little Dima and Equation
B. Little Dima and Equation time limit per test 1 second memory limit per test 256 megabytes input s ...
- 苹果未来:增强现实设备将会取代iPhone
近日,华尔街知名度相当高的苹果分析师木斯特(Gene Munster)决定转行组建自己的风险投资公司,临走前他发布了最后一份关于苹果的研究报告,他对苹果未来的发展进行了一番预测.Munster表示,以 ...
- Struts2 整合Spring(Maven,注解版)
这两天正在试验Struts2与Spring框架的整合,和他们各自的“注解”.今天就总结一下这两个框架怎么用注解进行整合. 一,加入两者的依赖包,除了两者的必要依赖外,还需要导入struts2-spri ...
- AngularJS 30分钟快速入门【译】
引用自:http://www.revillweb.com/tutorials/angularjs-in-30-minutes-angularjs-tutorial/,翻译如下: 简介 我三年前开始使用 ...
- html 之input标签height设置问题
今天针对这个问题纠结了很久 <input type="button" value="xx" style="height:99px;" ...
- PHP的开发环境
快速搭建工作环境,测试环境,开始PHP的编程之旅. liunx CentOS 6.4安装配置LAMP服务器(Apache+PHP5+MySQL) 准备篇: 1.配置防火墙,开启80端口.3306端口v ...
- easyloader源码
/** * easyloader - jQuery EasyUI * * Licensed under the GPL: * http://www.gnu.org/licenses/gpl.txt * ...
- jQuery插件开发(转)
jQuery插件开发全解析 jQuery插件的开发包括两种: 一种是类级别的插件开发,即给jQuery添加新的全局函数,相当于给jQuery类本身添加方法.jQuery的全局函数就是属于jQuery命 ...