C的结构体函数
#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的结构体函数的更多相关文章
- shell的编程结构体(函数、条件结构、循环结构)
bash&shell系列文章:http://www.cnblogs.com/f-ck-need-u/p/7048359.html 1.1 shell函数 在shell中,函数可以被当作命令一样 ...
- Swift基础(类,结构体,函数)
import Foundation // 创建一个类 class Student { // 属性(类的属性必须赋初值,如果不赋值,需要写自定义方法) var studentName: String v ...
- C/C++ 结构体 函数传递
#include <stdio.h> #include <stdlib.h> struct student{ int num; ]; double dec; }; void s ...
- c 结构体 & 函数指针模拟实现一个java class(类) 和方法
闲来无事,纯粹练习. student.h #ifndef STUDENT_H_INCLUDED #define STUDENT_H_INCLUDED #include <memory.h> ...
- go 结构体函数
package main import "fmt" type Dog struct { Name string } func (d *Dog) speak() string { r ...
- go 函数传递结构体
我定义了一个结构体,想要在函数中改变结构体的值,记录一下,以防忘记 ep: type Matrix struct{ rowlen int columnlen int list []int } 这是一个 ...
- foundation框架—结构体
Foundation框架—结构体 一.基本知识 Foundation—基础框架.框架中包含了很多开发中常用的数据类型,如结构体,枚举,类等,是其他ios框架的基础. 如果要想使用foundation框 ...
- 李洪强iOS开发之Foundation框架—结构体
Foundation框架—结构体 一.基本知识 Foundation—基础框架.框架中包含了很多开发中常用的数据类型,如结构体,枚举,类等,是其他ios框架的基础. 如果要想使用foundation框 ...
- 「Foundation」结构体
一.基本知识 Foundation—基础框架.框架中包含了很多开发中常用的数据类型,如结构体,枚举,类等,是其他ios框架的基础. 如果要想使用foundation框架中的数据类型,那么包含它的主头文 ...
随机推荐
- Python之爬虫-中国大学排名
Python之爬虫-中国大学排名 #!/usr/bin/env python # coding: utf-8 import bs4 import requests from bs4 import Be ...
- POJ 1995 (快速幂) 求(A1B1+A2B2+ ... +AHBH)mod M
Description People are different. Some secretly read magazines full of interesting girls' pictures, ...
- Springboot开启事务
参考资料: https://blog.csdn.net/message_lx/article/details/77584847
- selenium IDE脚本编辑与操作
1.编辑一行命令 在Table标签下选中某一行命令,命令由command.Target.value三部分组成.可以对这三部分内容那进行编辑. 然后右击这行命令,选择“Execute this comm ...
- Linux虚拟机安装学习笔记
一.Linux系统的安装1.VMwaer虚拟机的安装使用 官方下载软件地址:www.vmwaer.com 安装的虚拟机可以与现实的计算机进行通信 安装虚拟主机可以随意定制硬件安装配置建议: CPU:1 ...
- 添物不花钱学JavaEE(基础篇)-XML
XML(Extensible Markup Language) XML在日常工作中经常用到,必须有个了解,不过认识一下即可,不要太浪费时间.实际用到 参考图书 <XML入门经典>大而全,不 ...
- vimtips阅读记录
__BEGIN__ *vimtips.txt* For Vim version 8.0. ------------------------------------------------------- ...
- 笔记:Javac编译器
Javac编译器是把 *.java 文件转换为 *.class 文件,是一个前端编译器:对应着有一种把字节码转变为机器码的编译器,称为JIT编译器(Just In Time Compiler),比如 ...
- some 算法
矩阵变换:: 请用一条语句将: arr = [[1, 2, 3, 'a'], [4, 5, 6, 'b'], [7, 8, 9, 'c']] 转换装置矩阵为: [[1, 4, 7], [2, 5, 8 ...
- 我的arcgis培训照片8
来自:http://www.cioiot.com/successview-554-1.html