I've tried using this code to read the struct named packet, which includes priority(int), qty(float) and message (a sentence).
for(i = 0; i < 3; i++) {
scanf("%d%f", &packet[i].priority, &packet[i].qty);
gets(packet[i].message);
printf("\n%d %.6f ", packet[i].priority, packet[i].qty);
printf("%s\n", packet[i].message);
}
The problem is that I want it to print something like:
1 1 MESSAGE NUMBER ONE
2 1 MESSAGE NUM TWO
3 4 MESS NO THREE
But instead it prints
1 1
0 0 MESSAGE NUMBER ONE
2 1
Like the gets() doesn't execute when needed but instead delays the "for" by one step. Any ideas?