>>can you please give me a link to or a brief description of why scanf causes this mess.
This board is littered with discussions on input routines. I suggest you try finding a few via the search button.

>>does the function leave data within the buffer
Yes, scanf() will leave unwanted input in the input stream.

>>and then try to write over the existing data hence requiring it to be cleaned after every use to avoid the problem?
Err.. not sure where you going there.

>>does the gets and other input functions have similar voulnerabilities?
OK, never use gets(), that has other vulnerabilities. Stick to fgets() and you should be OK.