Guys if you dont mind i might need assistance with making a password lock program

I am trying to make a password lock program in DEV C++ my compiler does not agree with this program. pls i am not able to solve this one

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  #include<iostream>
  #inlcude<conio.h>
  #include<string.h>
  #include<stdio.h>
  using namespace std;
  int main()
{   
   char A[20];
   cout<<"Enter your password \n";
   gets(A);
   if(strcmp(A,"Thanosbuster")==0)
   cout<<"Welcome Mr Stark";
   else
   cout<<"Intruder alert";
   Sleep(9000)
   cls
}
   
   
Last edited on
pls guys pls help
You forgot a ; on line 15 , and on line 16, Cls is just meaningless.
what do you mean
oh yeah everything else is fine right?
You spelled "include" wrong on line 2.

Also, don't use conio.h ; it's not standard.

Likewise Sleep. Where is that function even coming from? It's not in any of those headers.

Also, you appear to have written this in C. Why not use C++?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <string>

int main()
{
  std::string password;
  std::cout << "Enter password: ";
  getline (std::cin, password);
  
  if (password == "Thanosbuster")
  {
   std::cout<<"Welcome Mr Stark";
  }
  else
  {
   std::cout<<"Intruder alert";
  }
}



You could use <thread> to make use a thing similar
to Sleep() :

1
2
3
4
5
6
7
#include <thread>//sleep_for and this_thread
#include <chrono>// seconds

int main(){
   std::this_thread::sleep_for(std::chrono::seconds(1));
   std::cout << "yay!";
}

They both kinda hold for a bit.
Last edited on
Topic archived. No new replies allowed.