Just keep it as a string, if you want it to print the 'a' too.
Code:
printf("%s is your number\n", buffer);
Unless you mean you want it to reject the input...
Code:
int i = 0;
int l = strlen(buffer);
while(i != l)
{
printf("Enter a number: ");
if(!(fgets(buffer,sizeof buffer,stdin)))
exit(0);
for(i = 0; i < l; i++)
if(!isdigit(buffer[i]))
i = l + 1;
}
if(!(sscanf(buffer,"%d",&x)))
exit(0);
I think that will do what you want... If you want it to reject invalid input.
// Sorry, was typing during your second post... Don't know of another way..