#include<stdio.h>
#include<string.h>
struct Test
{
int age;
char name[];
double score;
}std1;
//结构体函数
struct Test struct_fun(int age,char *name,double score){
struct Test Student;
Student.age=age;
//Student->name=name; 错误,字符串不能直接赋值,可以初始化
//example :char NAME[16]="hello";
strcpy(Student.name,name);
Student.score=score; return Student;
}
void output_fun1(int age,char *name,double score){
std1.age=age;
strcpy(std1.name,name);
std1.score=score;
printf("output_fun1 :\n");
printf("age=%d,name=%s,score=%.2f\n",std1.age,std1.name,std1.score);
}
//结构体函数输出
void output_fun2(struct Test stu){
printf("output_fun2 :\n");
printf("age=%d,name=%s,score=%.2f",stu.age,stu.name,stu.score);
} void main(){
output_fun1(,"xiaoming",); struct Test p=struct_fun(,"xiaohong",);
output_fun2(p);
}

C的结构体函数的更多相关文章

  1. shell的编程结构体(函数、条件结构、循环结构)

    bash&shell系列文章:http://www.cnblogs.com/f-ck-need-u/p/7048359.html 1.1 shell函数 在shell中,函数可以被当作命令一样 ...

  2. Swift基础(类,结构体,函数)

    import Foundation // 创建一个类 class Student { // 属性(类的属性必须赋初值,如果不赋值,需要写自定义方法) var studentName: String v ...

  3. C/C++ 结构体 函数传递

    #include <stdio.h> #include <stdlib.h> struct student{ int num; ]; double dec; }; void s ...

  4. c 结构体 & 函数指针模拟实现一个java class(类) 和方法

    闲来无事,纯粹练习. student.h #ifndef STUDENT_H_INCLUDED #define STUDENT_H_INCLUDED #include <memory.h> ...

  5. go 结构体函数

    package main import "fmt" type Dog struct { Name string } func (d *Dog) speak() string { r ...

  6. go 函数传递结构体

    我定义了一个结构体,想要在函数中改变结构体的值,记录一下,以防忘记 ep: type Matrix struct{ rowlen int columnlen int list []int } 这是一个 ...

  7. foundation框架—结构体

    Foundation框架—结构体 一.基本知识 Foundation—基础框架.框架中包含了很多开发中常用的数据类型,如结构体,枚举,类等,是其他ios框架的基础. 如果要想使用foundation框 ...

  8. 李洪强iOS开发之Foundation框架—结构体

    Foundation框架—结构体 一.基本知识 Foundation—基础框架.框架中包含了很多开发中常用的数据类型,如结构体,枚举,类等,是其他ios框架的基础. 如果要想使用foundation框 ...

  9. 「Foundation」结构体

    一.基本知识 Foundation—基础框架.框架中包含了很多开发中常用的数据类型,如结构体,枚举,类等,是其他ios框架的基础. 如果要想使用foundation框架中的数据类型,那么包含它的主头文 ...

随机推荐

  1. node Buffer.byteLength()

    Buffer.byteLength(string[, encoding]) string {String} | {Buffer} | {TypedArray} | {DataView} | {Arra ...

  2. Python 3安装体验篇(win10)

    一.下载 1.打开官网https://www.python.org/downloads/windows/,点击Python 3版本链接 2.点击win10 64位安装链接,即可下载Python安装 二 ...

  3. DataBase安装及简单配置

    下载以及安装 打开mysql官网下载页面:http://dev.mysql.com/downloads/mysql/ 用管理员身份打开cmd命令行工具,cd到解压文件的bin目录 输入mysqld i ...

  4. mac 文本处理命令分享

    mac 文本处理命令分享 */--> pre.src {background-color: #292b2e; color: #b2b2b2;} pre.src {background-color ...

  5. HTML、CSS常用技巧

    一.HTML 在介绍HTML之前,我们先看一下HTML的文档树结构,主要包括哪些: (一).头部标签 1,Doctype Doctype告诉浏览器使用什么样的HTML或XHTML规范来解析HTML文档 ...

  6. 【Codeforces 1041D】Glider

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 二分. 枚举每一个上升区的起始位置作为起点(这样做肯定是最优的),然后如果没有掉在地上的话就尽量往右二分(只有上升区之间的间隙会让他往下掉) ...

  7. 图论算法——最短路径Dijkstra,Floyd,Bellman Ford

    算法名称 适用范围 算法过程 Dijkstra 无负权 从s开始,选择尚未完成的点中,distance最小的点,对其所有边进行松弛:直到所有结点都已完成 Bellman-Ford 可用有负权 依次对所 ...

  8. jsp+servlet+mysql增删改查

    用的IntelliJ IDEA开发的,jdk1.8 1 首先是项目结构,如下图所示 2看各层的代码 首先是web.xml <?xml version="1.0" encodi ...

  9. BNUOJ 9870 Contestants Division

    Contestants Division Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVALiv ...

  10. codevs——1031 质数环

    1031 质数环  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题解  查看运行结果     题目描述 Description 一个大小为N(N<=17 ...