Thread: password

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    39

    password

    i want the password to be the inverted login.e.g
    logname=2345
    password=5432

    i have written the following code but it is not doing well!


    char temp[10],temp1[10],temp2[10];
    bool state=false;

    cout<<"Enter the ID(10 characters long): ";
    cout.flush();
    gets(temp1);

    for(count=0,counter=9;count<10;count++,counter--)
    temp2[count]=temp1[counter];

    temp2[count]='\0';

    cout<<"Enter the Password(10 characters long): ";

    do
    {
    cout.flush();
    temp[0]= getch();
    cout<<"*";
    cout.flush();
    temp[1]= getch();
    cout<<"*";
    cout.flush();
    temp[2]= getch();
    cout<<"*";
    cout.flush();
    temp[3]= getch();
    cout<<"*";
    cout.flush();
    temp[4]= getch();
    cout<<"*";
    cout.flush();
    temp[5]= getch();
    cout<<"*";
    cout.flush();
    temp[6]= getch();
    cout<<"*";
    cout.flush();
    temp[7]= getch();
    cout<<"*";
    cout.flush();
    temp[8]= getch();
    cout<<"*";
    cout.flush();
    temp[9]= getch();
    cout<<"*";

    if( strcmp ( temp , temp2 ) == 0 )
    state = true;
    else
    cout<<"Wrong password\n";

    }while (state == false);

  2. #2
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    If the password itself isn't working, then it's probably because there is 3 declared char temp's, and 11 temp's in the code
    [EDIT]Use Code Tags Next Time Also![/EDIT]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading a password from a file.
    By medeshago in forum C Programming
    Replies: 15
    Last Post: 12-21-2008, 07:20 AM
  2. [Q]Hide Password
    By Yuri in forum C++ Programming
    Replies: 14
    Last Post: 03-02-2006, 03:42 AM
  3. written command line password generator
    By lepricaun in forum C Programming
    Replies: 15
    Last Post: 08-17-2004, 08:42 PM
  4. Password prompt in unix w/o \b
    By rafe in forum C++ Programming
    Replies: 1
    Last Post: 10-09-2002, 08:54 AM
  5. password
    By hammers6 in forum C Programming
    Replies: 1
    Last Post: 10-10-2001, 12:14 AM