Digite C. Scanf antes de receber. Problema

Eu sou muito novo em C e tenho um problema com a entrada de dados no programa.

Meu código:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
   int a;
   char b[20];

   printf("Input your ID: ");
   scanf("%d", &a);

   printf("Input your name: ");
   gets(b);   

   printf("---------");

   printf("Name: %s", b);   

   system("pause");
   return 0;
}

Permite inserir o ID, mas apenas ignora o restante da entrada. Se eu mudar a ordem assim:

printf("Input your name: ");
   gets(b);   

   printf("Input your ID: ");
   scanf("%d", &a);

Vai funcionar. Embora, NÃO POSSO alterar a ordem e preciso exatamente como está. Alguém pode me ajudar ? Talvez eu precise usar outras funções. Obrigado!

questionAnswers(8)

yourAnswerToTheQuestion