【发布时间】:2017-08-09 23:15:53
【问题描述】:
我正在编写一个程序,要求飞行员输入坐标。然后,稍后在其他功能中使用这些坐标,例如计算平面的距离和角度
这是我的主要功能:
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.js 中声明它们。我之前声明过它们。我只是在 main 中调用了它们
-
"我希望程序返回主函数并继续执行其他函数。" 这些不是函数调用,它们是前向声明。