#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. PyQt5+requests实现车票查询工具

    PyQt5+requests实现一个车票查询工具,供大家参考,具体内容如下 结构图   效果图   思路 1.search(QPushButton)点击信号(clicked)连接到自定义的槽函数(ev ...

  2. C语言学习8

    计算某日是该年的第几天 编写一个计算天数的程序,用户从键盘输入年.月.日,在屏幕中输出此日期是该年的第几天. /******************************************** ...

  3. 基于vue实现模糊匹配(这里以邮箱模糊匹配为例,其他的模糊匹配都可以类比)

    html部分(主要部分): js: data: methods: 效果图:

  4. 集训第四周(高效算法设计)C题 (二分查找优化题)

    Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...

  5. Texture 纹理贴图

    基础贴图Shader:只有纹理 1. 在属性中声明纹理贴图: _MainTex ("Texture", 2D) = "white" {} 2. 在Pass中声明 ...

  6. 创建Javaweb项目及MyEclipse视图的配置

    在myEclipse里--右键new--Web Project 视图的配置--Window--Show View-Other在里面输入要找的视图例如(servers)或者直接 Window--rese ...

  7. 用PowerPoint中的VB实现课件中的智能交互

    http://www.duxiushan.net/index.asp?xAction=xReadNews&NewsID=294 我们使用PPT的目的只有一个,即更好地达成“沟通.演说.汇报.讲 ...

  8. [luoguP2444] [POI2000]病毒(AC自动机 + dfs)

    传送门 先把所有串建一个AC自动机, 如果要找一个不包含任意一个串的串, 说明这个串一直在AC自动机上匹配但匹配不到, 也就是说,匹配时除去val值为1的点,除去fail指针指向val值为1的点,是否 ...

  9. android中webview的实现

    设置从当前页面打开链接,而不是跳转到系统默认浏览器打开: webview.setWebViewClient(new WebViewClient(){ @Override public boolean ...

  10. hadoop(2)hadoop配置

    hadoop入门(二) hadoop的配置 1.本地模式 2.伪分布式 3.分布式     一.配置linux环境: 1打开虚拟网络编辑器,选择 VMnet1 仅主机模式, 子网 IP 设为 192. ...