这是我编写的一个程序,用于计算飞机起飞时间,并且飞行一秒钟。但是当我运行程序并在控制台中插入第一个数字时,它会立即崩溃。
#include <stdio.h>
int main (void) {
int m, s;
int u;
long flight, landing;
printf("insert time of taking a plane:\n time in hours: ");
scanf("%d, &u");
printf(" minutes: ");
scanf("%d", &m);
printf(" seconds: ");
scanf("%d", &s);
printf("Duration of a flight (in seconds): ");
scanf("%ld", &flight);
pristanek = u * 3600 + m * 60 + s + let;
u = landing / 3600;
m = (landing % 3600) % 60;
s = landing % 60;
printf("Time of landing; %d:%02d:%02d\n", u, m, s);
return 0;
}
答案 0 :(得分:4)
这是因为scanf
的正确语法是:
scanf("%d", &u); // notice the " is after the "d"
你实际上已经在其他scanf
中做到了。