(This is about C, not C++...)

I'm just fiddling with reading some simple user input. The idea is that the user enters a string of less than 20 chars long and then later on enters their age as an integer.

A problem arises if the user enters "asdflajsdkjflakjsdlflajsldjlfajlkdlkjfasdfkjjfaiou" and hits enter. Only the first 19 chars are read (which is good), but the rest is left on the stdin stream. Thus when the age is requested, the remaining text is read straight away.

My Question:
Is there a built-in function that will let me clear out whats remaining in stdin? I have thought of just using a loop to get eat all the remaining queued-up bytes, but that seems a bit messy to me for some reason.

I put 2 comments in th places where I need to clear out the input...

Code:
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
	char firstName[20];
	int end = 0;
	int age = -1;

	printf("Please enter your first name\n: ");
	fgets(firstName, sizeof(firstName), stdin);	//read the user's name from stdin
	
	/*flush input here?*/

	end = strlen(firstName) - 1;

	if(firstName[end]=='\n')
		firstName[end] = '\0'; //kill the newline if there is one

	printf("Hello %s, enter your age: ", firstName);
	scanf("%d", &age);

	/*flush input again here?*/

	if(age < 18)
		printf("You are a mere pipsqueak!");
	else if(age < 25)
		printf("You are a noob!");
	else if(age < 30)
		printf("You are a budding expert!");
	else if(age < 50)
		printf("You are an old fart!");
	else if(age < 75)
		printf("You are a grizzled ancient!");

	printf("\n");
	
	return 0;
}