我正在写一个程序,要求飞行员输入坐标。我的void函数返回一个值并且不返回到主函数。
int main()
{
plane_checker();
double angle_finder(int x, int y);
double distance_plane(int x, int y, int z);
void ils_conditions();
}
在我的plane_checker()
功能是:
plane_checker()
{
printf("Please enter your identification code:");
scanf("%s", &plane_name[0]);
if((plane_name[0]== 'j') || (plane_name[0]== 'f') || (plane_name[0]== 'm') || (plane_name[0]== 'J') || (plane_name[0]== 'F') || (plane_name[0]== 'M'))
{
printf("Sorry, we are not authorized to support military air vehicles.");;
}
else
{
printf("Please enter your current coordinates in x y z form:");
scanf("%d %d %d", &x, &y, &z);
if(z < 0)
{
printf("Sorry. Invalid coordinates.");
}
}
return;
}
然后,在其他功能,如计算距离和平面
这是我的主要功能的角度以后使用这些坐标
用户输入坐标后,我期望程序返回到主功能并继续执行其他功能。但是,当我运行程序时,我的函数返回输入的z值并结束程序。如在这里看到的:
Please enter your identification code:lmkng
Please enter your current coordinates in x y z form:1 2 2
Process returned 2 (0x2) execution time : 12.063 s
Press any key to continue.
这可能是什么原因造成的?我一字一句地检查了我的程序,但是找不到原因呢?我错过了什么?
非常感谢您提前!
@Schwern我没有在main中声明它们。我之前宣布过他们。我只是在主 – Huzo
中调用它们“*我希望程序返回到主函数并继续执行其他函数。”这些不是函数调用,它们是前向声明。 – Schwern