Correct me if I'm wrong ( I haven't used char in FOREVER ), but isn't he passing a single letter to password then rewriting it with the next loop?
char con; <small>Single Charactor</small>
while(Con!=13) <small>While Con != CR</small>
{
Con=getch();
Password+=Con;
cout<<"*";
}
int i = 0;
while(Con!=13){
Con=getch();
Password[i] = Con;
cout<<"*";
i++;
}
Password[i] = '\0'
You could use GetLine().
std::string Password;
std::cout << "Please, enter your password: ";
std::getline (std::cin,password);
password.compare("Quasim...........
Although I am assuming your doing single character so you can replace it with a '*'
Also it's never really a good idea to use system calls. Windows has a sleep() function to pause and Clearing the screen is a little more difficult
#include <windows.h>
#include <iostream>
int main(int argc, TCHAR argv[])
{
HANDLE hStdout;
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
cls(hStdout);
}
void cls( HANDLE hConsole )
{
COORD coordScreen = { 0, 0 };
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
if( !GetConsoleScreenBufferInfo( hConsole, &csbi ))
return;
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
if( !FillConsoleOutputCharacter( hConsole, (TCHAR) ' ',
dwConSize, coordScreen, &cCharsWritten ))
return;
if( !GetConsoleScreenBufferInfo( hConsole, &csbi ))
return;
if( !FillConsoleOutputAttribute( hConsole, csbi.wAttributes,
dwConSize, coordScreen, &cCharsWritten ))
return;
SetConsoleCursorPosition( hConsole, coordScreen );
}</iostream></windows.h>
http://www.cplusplus.com/forum/beginner/1988/3/#msg10830[
^] Again Windows
http://www.cplusplus.com/forum/beginner/43683/[
^]
Shows how to hide your text so you could use getline(). Remember Google is everybodys best friend, because every problem you will encounter, good chance some one already did and posted a solution.