i havin problem to clear the buffer this is the following condition

Prompts being printed multiple times or your program "skipping" over prompts because left over input was accepted automatically. These problems are a symptom of not using buffer overflow code often enough.

Program halting at unexpected times and waiting for the user to hit enter a second time. Calling your buffer clearing code after every input routine without first checking if buffer overflow has occurred causes this.

Using fflush(stdin). This function is not appropriate for reasons mentioned
Using rewind(stdin). This function is not appropriate as it is not intended to be used for buffer clearing.

The use of buffer clearing code may have been avoided with gets() or scanf() for scanning string input. These functions are not safe because they do not check for the amount of input being accepted.

Using long characters arrays as a sole method of handling buffer overflow. We want you to use the readRestOfLine() function.
Other buffer related problems.

For example, what happens in your program when you try to enter a string of 40 characters when the limit is 20 characters?

Code:
/**************************************
 * Function readRestOfLine() is used for buffer clearing.
 *************************************/
void readRestOfLine(){
   int c;
   /* Read until the end of the line or end-of-file. */   
   while ((c = fgetc(stdin)) != '\n' && c != EOF)
      ;
   /* Clear the error and end-of-file flags. */
   clearerr(stdin);
}
thanks for the help