Below is my source code. After I read the integer, the program should wait until I type a string and then press enter. However, as soon as I enter the integer, the program exits. Can you tell me where is my fault?
#include <stdio.h>
#include <string.h>
int main()
{
    int n;
    char command[255];
    scanf("%d", &n);
    fgets(command, 255, stdin);
    return 0;
}
I mention that I also tried to use gets(command), but I get the same result.
 
     
     
     
     
    