5 Replies - 2045 Views - Last Post: 04 March 2012 - 04:23 PM Rate Topic: -----

#1 irwin08  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 04-March 12

I am trying to write a password login for cmd with c++

Posted 04 March 2012 - 01:39 PM

hi im new to c++ and am trying to make a lock for my cmd. when i type in my password it skips the if and goes to the else. idk what im doing wrong plz help. oh and im using bloodshed dev c++. and i havent added system ("cmd.exe") to the if part yet because it doesnt compile rite for some reason.
 
#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
cout<< "Please enter your password";
char password
char admin
cin>> password ;

if (password == admin)
cout<<"Hello admin";

else
cout<<"ERROR_REPORT WRONG PASSWORD" ;

system ("pause")
return 0;
}



Is This A Good Question/Topic? 0
  • +

Replies To: I am trying to write a password login for cmd with c++

#2 simeesta  Icon User is offline

  • Deadly Ninja


Reputation: 219
  • View blog
  • Posts: 592
  • Joined: 04-August 09

Re: I am trying to write a password login for cmd with c++

Posted 04 March 2012 - 02:00 PM

password and admin need to be strings not chars. You'll also need to include the string header file and to assign the correct password to admin.

You're also missing two ';' on lines 9 and 10.
Was This Post Helpful? 1
  • +
  • -

#3 irwin08  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 04-March 12

Re: I am trying to write a password login for cmd with c++

Posted 04 March 2012 - 03:52 PM

thx very much it worked! :bananaman:
Was This Post Helpful? 0
  • +
  • -

#4 irwin08  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 04-March 12

Re: I am trying to write a password login for cmd with c++

Posted 04 March 2012 - 04:04 PM

hi im am newto c++ and wondering if there is away to set a string so it will be permanent and wont be able to change it the next time you open the app. thx
Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6052
  • View blog
  • Posts: 23,487
  • Joined: 23-August 08

Re: I am trying to write a password login for cmd with c++

Posted 04 March 2012 - 04:17 PM

Merged duplicate topics. Don't create a new topic on a problem you've already posted about.
Was This Post Helpful? 0
  • +
  • -

#6 simeesta  Icon User is offline

  • Deadly Ninja


Reputation: 219
  • View blog
  • Posts: 592
  • Joined: 04-August 09

Re: I am trying to write a password login for cmd with c++

Posted 04 March 2012 - 04:23 PM

Like this?
const string s = "hello";


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1