Casting 为什么将float返回int可以工作,而复制不能?

Casting 为什么将float返回int可以工作,而复制不能?,casting,Casting,#include#include typedef struct{int i;float f;}num 无效函数(浮动*);float getnumber() int main(){num*ex=malloc(sizeof(num));func(&ex->i);printf(“Number=%d\n”,ex->i);ex->i=getnumber();printf(“Number=%d\n”,ex->i);free(ex);} void func(float*num){*num=4.2;} flo

#include#include typedef struct{int i;float f;}num

无效函数(浮动*);float getnumber()

int main(){num*ex=malloc(sizeof(num));func(&ex->i);printf(“Number=%d\n”,ex->i);ex->i=getnumber();printf(“Number=%d\n”,ex->i);free(ex);}

void func(float*num){*num=4.2;}

float getnumber(){return 1.2;}