我正在寫一個程序,要求飛行員輸入座標。我的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