Don't know if its the ideal solution...but it works
Code:
#include <stdio.h>
int main() {
          int number;
          printf("Enter an integer:");

          if (scanf("%[0-9]d", &number)!=1) {
                printf("You didn't type in a number");
                getchar();
          }
    return 0;
 }