ポインターと malloc を使用してプログラムに Scanf の結果をメモリに保存させようとしています。Scanf が整数のみを受け入れるようにしたいのは私のコードです。結果を印刷すると、乱数が返されますか??
int main(void)
{
unsigned int *Source = malloc(10);
printf("Enter a Source Number: ");
scanf("%i",Source);
printf("%i\n",Source);
unsigned int *Destination = malloc(4);
printf("Enter a Destination Number: ");
scanf("%i",Destination);
printf("%i\n",Destination);
unsigned int *Type = malloc(4);
printf("Enter a Type Number: ");
scanf("%i",Type);
printf("%i\n",Type);
int *Port = malloc(4);
printf("Enter a Port Number: ");
scanf("%i",Port);
printf("%i\n",Port);
char *Data;
struct Packet *next;
return 0;
}
誰もこれを説明できますか?