源代码:
#include <stdio.h>
#include <string.h>
struct book
{
char bookname[30];
double quantity;
};
double fun(struct book *q)//函数类型为double,返回值也必须是double
{
double ret1;
char ret2;
ret1 = q->quantity + 2020;
// ret2 = q->bookname;
return ret1; //返回指定类型的参数
// return (ret1,ret2);//返回指定类型的参数
}
main()
{
struct book boo = {"cc", 10.11111};
double num = fun(&boo);//赋上参数10
char char_num = fun(&boo); //赋上字符参数
printf("赋上参数======%lf\n", num);//打印调用的计算结果
}
执行结果:
赋上参数======2030.111110
[Thread 34728.0x2f58 exited with code 30]
[Inferior 1 (process 34728) exited with code 036]