首页 > 编程语言 > 详细

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

时间:2016-12-11 08:04:52      阅读:148      评论:0      收藏:0      [点我收藏+]
 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 
 4 struct student{
 5     int num;
 6     char str[20];
 7     double dec;
 8 };
 9 
10 void scan(struct student *stu){
11 //    scanf("%d%s%lf", &stu->num, stu->str, &stu->dec);
12     scanf("%d%s%lf", &(*stu).num, (*stu).str, &(*stu).dec);//.运算符优先级大于*
13 }
14 
15 void print(struct student stu){
16     printf("%d %s %lf\n", stu.num, stu.str, stu.dec);
17 }
18 
19 int main(){
20 
21     struct student stu;
22     
23     scan(&stu);
24     print(stu);
25 
26     return 0;
27 }
28 /*
29 20 字符串 20.02
30 */

 

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

原文:http://www.cnblogs.com/xuqiulin/p/6158946.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!