我有以下结构:
typedef struct number
{
int x;
int y;
int z;
unsigned long int final;
}number;
我的代码如下:
number* numbers;
numbers= (number*)malloc(sizeof(number));
scanf("%d %d %d", &numbers->x, &numbers->y, &numbers->z);
printf("input: %d,%d,%d\n",numbers->x, &numbers->y, &numbers->z);
numbers->final=(numbers->x)*4000 + (numbers->y)*50 + (numbers->z);
printf("final: %d",numbers->final);
但输出是错误的。例如这里是一个运行:
12 12 12
input: 12,12,12
final: -28640
我无法弄清楚问题所在。number->final 可以得到的最高数字是90,000(我在给出输入时确保它)......我似乎有重叠?请帮忙。