Thread: Regarding Resetting password

  1. #1
    Registered User
    Join Date
    Feb 2017
    Posts
    1

    Post Regarding Resetting password

    Hi Everyone,

    I have doubt regarding in this code. I need to reset the password of user this code. The default password has to overwrite in the code. Please help me.

    Thanks
    Deepak

    Code:
    #include <stdio.h>
    #include <string.h>
    #include <conio.h>
    #include <stdlib.h>
    
    
    char admin_user[20]    = "Enamel";
    char product_user1[20] = "Enamel1";
    char product_user2[20] = "Enamel2";
    char product_user3[20] = "Enamel3"; 
    char product_user4[20] = "Enamel4"; 
    char product_user5[20] = "Enamel5";
    
    
    char admin_password[20] = "Mumbai";
    char user1_password[20] = "Mumbai1";
    char user2_password[20] = "Mumbai2"; 
    char user3_password[20] = "Mumbai3"; 
    char user4_password[20] = "Mumbai4"; 
    char user5_password[20] = "Mumbai5";  
    
    
    void change_password(void);
    
    
    int main (void)
    
    
    {
        int i, j, k, l, m, n;
        char var_admin[20], var_product1[20], var_product2[20], var_product3[20], var_product4[20], var_product5[20];
        char admin_pass[25] = {0}, prod1_pass[25] = {0}, prod2_pass[25] = {0}, prod3_pass[25] = {0}, prod4_pass[25] = {0}, prod5_pass[25] = {0};
        char buff1[25], buff2[25], buff3[25], buff4[25], buff5[25];
        char c;
        int pos = 0;
        
        printf("Enter Admin User Name:\n");
        
        while((var_admin[i] = getchar())!='\n')
            i++ ;
            
        printf("Enter Password for admin:\n");
        
        do {
            c = getch();
    
    
            if( isprint(c) ) 
            {
                admin_pass[ pos++ ] = c;
                printf("%c", '*');
            }
            else if( c == 8 && pos )
            {
                admin_pass[ pos-- ] = '\0';
                printf("%s", "\b \b");
            }
        } while( c != 13 );
    
    
        if(!strcmp(admin_pass, admin_password))
        {
            printf("\n%s\n", "Logged on succesfully!");
            printf("Do you want to manage password? \n");
            
            printf("Yes for changing password\n");
            printf("No for Unchanging the password\n");
            
            scanf("%s", buff1);
            
            if(buff1 == "YES")
            
            {
                printf("Change Password");
            }
            
            else
            
            {
                printf("Dont Change Password");
            }
        }
        else 
        {
            printf("\n%s\n", "Incorrect login!");
        }
            
        return 0;
    
    
    }
    
    
    void change_password(void)
    {
        
    }

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    This is C code. And should be moved to appropriate forum
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Look up the function strncpy.
    Also, this line of code is wrong; if you are doing C programming.
    Code:
    if(buff1 == "YES")
    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 06-29-2014, 02:08 AM
  2. Replies: 2
    Last Post: 01-07-2009, 10:35 AM
  3. Resetting std:vector?
    By DrSnuggles in forum C++ Programming
    Replies: 7
    Last Post: 09-06-2008, 03:53 PM
  4. Resetting stdin after EOF
    By o0zi in forum C Programming
    Replies: 4
    Last Post: 05-22-2005, 08:04 AM
  5. Resetting the WM_TIMER
    By conright in forum Windows Programming
    Replies: 1
    Last Post: 01-04-2003, 12:02 AM

Tags for this Thread