私はprintf体重、ドラッグ、時間が0の場合、値が重量、ドラッグ、時間変数(構造体USER_INPUT内)に格納されていない理由を知りません。 私はプログラムの残りの部分、私は主な機能でいくつかの間違いを犯しましたか?関数getInputで何が問題になっていますか?
#include <stdio.h>
#define G 9.8
#define index 3
typedef struct
{
double weight;
double drag;
double time;
}USER_INPUT;
double velocities[index];
double getInput(USER_INPUT);
double calculateVelocities(USER_INPUT);
void main(void)
{
double velocity;
USER_INPUT input;
getInput(input);
calculateVelocities(input);
printf("Velocities for the parachuties with weight %f\n", input.weight);
printf("and a drag coefficient %f\n", input.drag);
printf("\n\n Time Velocities m/s\n");
printf("---------------------------------\n");
printf(" %f %f\n", input.time, velocities[0]);
printf(" %f %f\n", input.time, velocities[1]);
printf(" %f %f\n", input.time, velocities[2]);
}
double getInput(USER_INPUT input)
{
printf("Please enter weight, drag and time:\n");
scanf("%lf %lf %lf", &input.weight, &input.drag, &input.time);
printf("%f %f %f\n"), input.weight, input.drag, input.time;
}
double calculateVelocities(USER_INPUT input)
{
velocities[0]=1;
velocities[1]=2;
velocities[2]=3;
}
はどうもありがとうございました! – user133174
@ user133174問題ありません! –
'&((* input).weight)'を '&input-> weight'と比較するのは本当にお勧めできません。前者は難解であり、明確化ではない。 –