1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Can't seem to get this right.

Discussion in 'C' started by oreo, Sep 2, 2010.

  1. oreo

    oreo New Member

    Joined:
    Sep 2, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Okay, so I am currently making a program that would ask for your password and if it's wrong, it would ask again. Yes, it is simple but I am trying to make it a bit different.
    I noticed that whenever the password is wrong, it would make another print and would ask again, and it makes the output long so I thought of if a user had the password wrong, it would remove the wrong password that the user have entered and would ask again in the same line

    try the code below:

    Code:
    main()
    {
     int pass;
     clrscr();
      do
       {
        clrscr();
        printf("Enter Password:");
        scanf("%d",&pass);
       }
       while (pass!=12345);
        printf("contrats!");
    
       getch();
    }
    my problem is, I can't seem to place, "Error. Invalid Password, please try again" after the user would input the password. It looks so wrong because the moment I run the program, it would say "Error. Invalid Password, please try againEnter Password:"
    so i'm kind of a confused on how i am going to place it.
    Also, I'm new to this kind of stuffs so please help me understand.

    Love,
    Oreo
     

Share This Page