【发布时间】:2018-01-08 17:49:32
【问题描述】:
谁能指出我做错了什么,我对c编程很陌生。 我不断收到“组件”错误的冲突类型。
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
float Vo,ang;
printf("Enter Velocity:");
scanf("%f",&Vo);
printf("Enter Angle:");
scanf("%f",&ang);
printf("The x component is %f and the y component is %f",components(Vo,ang));
}
float components(float Vo, float ang,float Vx, float Vy)
{
Vx=Vo*cos(ang);
Vy=Vo*sin(ang);
return Vx,Vy;
}
我将不胜感激。
【问题讨论】:
-
除了编译器错误(在下面的答案中解决),让我提一下
return Vx,Vy;几乎可以保证不会做你期望的事情。 -
您返回多个值的方式不正确。见How do I return multiple values from a function in C?
标签: c compiler-errors