#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. C++ 赋值运算符重载

    类的定义 class Test{ int id; public: Test(int i): id(i){ cout << "obj_" << i <& ...

  2. Anaconda基本用法

    Anaconda基本用法 conda info --envs/(-e) // 查看当前的环境变量 conda create -n py36(环境的名称,随意) python=3.6(指定版本) //  ...

  3. python基础示例

    7.写代码 (1)实现用户输入用户名和密码,当用户名为 seven 且 密码为 123 时,显示登陆成功,否则登陆失败! _name = "seven" _pwd = " ...

  4. 【判断二分图】C. Catch

    https://www.bnuoj.com/v3/contest_show.php?cid=9154#problem/C [题意] 给定一个无向图,给定小偷的起始位置 从这个起始位置开始,小偷可以在单 ...

  5. Thinkphp5.0 的实践一

    Thinkphp5.0 的实践一 tp5.0默认没有__SELF__,需要定义, define('__SELF__',strip_tags($_SERVER['REQUEST_URI'])); tp5 ...

  6. Surprising Strings

    Surprising Strings Time Limit: 1000MS Memory Limit: 65536K Total Submissions: Accepted: Description ...

  7. java设计模式——单例设计模式

    /*设计模式:对问题行之有效的解决方式.其实它是一种思想. 1,单例设计模式.    解决的问题:就是可以保证一个类在内存中的对象唯一性. 必须对于多个程序使用同一个配置信息对象时,就需要保证该对象的 ...

  8. Errors running builder 'JavaScript Validator' on

    eclipse编译提示Errors running builder 'JavaScript Validator' on 解决方法见下图 去掉 'JavaScript Validator' 即可

  9. python 进程内存增长问题, 解决方法和工具

    转载:http://drmingdrmer.github.io/tech/programming/2017/05/06/python-mem.html#pyrasite-%E8%BF%9E%E6%8E ...

  10. Windows上安装Mac OS

    在windows上开发ios程序,是一件比較痛苦的事情.由于: 开发android程序,使用eclipse.eclipse有windows版同一时候也有mac版,所以mac上开发android程序和w ...