Here my situation, the users of my application are asked to enter their password to start it. To get the password I simply use:
char c;
std::string password;
while ... // until the end of entry
{
c = fgetc(stdin);
password += c;
}
Once the password is checked I destroy the variable so it can't be retrieved using a core image of my program. For instance if someone use "gcore" command and then search for the password in the core generated it will not find it.
But in my case, I can still retrieve the password value because it seems that it is still in stdin buffer.
So my question is how can I clear stdin buffer in order to make the values typed by user not available in memory anymore ?
For information I already tried: fflush, __fpurge, fwrite (from the beginning position of stdin stream)... and nothing seems to work.
Thank you in advance.