私は4つの異なる関数でこのコードを書いています。その主な目的は角度0〜90のテーブルに表示することです。角度、時間、速度の距離です。速度はユーザから入力される。 しかし、関数を作成しているvoid関数を呼び出すと、「create_table 'への未定義の参照」エラーが発生します。これは私のコードです。Cの空関数を呼び出す方法
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define G 9.8 /* gravitation acceleration 9.8 m/s^2 */
#define PI 3.141592654
void create_table(double v);
double Projectile_travel_time(double a, double v);
double Projectile_travel_distance(double a, double v);
double degree_to_radian(double d);
int main(void)
{
int n;
double velocity;
printf ("please enter the velocity at which the projectile is launched (m/sec): ");
n = scanf("%lf" ,&velocity);
if(n != 1)
{
printf("Invlid input. Bye...");
exit(1);
}
while (velocity < 0)
{
printf ("please enter a positive number for velocity: ");
n = scanf("%lf", &velocity);
if(n != 1)
{
printf("Invlid input. Bye...");
exit(1);
}
}
create_table(velocity);
return 0;
}
void create_table(double v)
{
printf("Angle t d\n");
printf("(deg) (sec) (m)\n");
double a,i;
for(a=0; a<=90; a+=5)
{
for(i=0; i<=2; i++)
{
double t = Projectile_travel_time(a, v);
double s = Projectile_travel_distance(a, v);
printf("%d %d %d\n", a, t, s);
}
}
}
double Projectile_travel_time(double a, double v)
{
double t = ((2*v*sin(degree_to_radian(a)))/(G));
return t;
}
double Projectile_travel_distance(double a, double v)
{
double d = ((v*v)/G)*sin(2*degree_to_radian(a));
return d;
}
double degree_to_radian(double d)
{
double r = d*atan(1) * 4/180;
return r;
}
助けていただければ幸いです。 おかげ
編集私は、コードを編集しているが、今、私の出力は完全にオフされた状態で、別の問題が発生しています。どのように私の機能が間違っているか提案?
メイン以外の機能を定義する必要があります。 – jboockmann