I have just started C++ and have some experience with C# so I have some programming experience in general. However, seems like straight away I have been shot down. I have tried looking on Google so not to waste anyone's time to no avail.
int main(int argc, char *argv[])
{
HANDLE hConsole;
int k = 5;
string h;
string password = "pass";
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, k);
SetConsoleTextAttribute( GetStdHandle( STD_INPUT_HANDLE ), 0x5B );
while (h != password)
{
printf("This PC is locked\nEnter the password to gain access\n");
scanf("%s", &h);
}
printf("\n");
system("PAUSE");
return EXIT_SUCCESS;
}
Whenever I run this it will get me to enter the password and when I click enter it will acknowledge and then crash asking me to either debug or send information to Microsoft. This started when I added the while loop checking two strings. Have I executed this correctly or have I missed something?
Just in case its not clear. I want the program to compare a string with an input and if they are both the same the program will end.
Thanks for looking.