Thread: question about precedence (i think)

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    8

    question about precedence (i think)

    This is my problem:
    I want to have "Password: " before my input... for example:

    Password: _

    _=cursor.

    for my code:

    cout<<"Password: ";

    for(i=0;i<16;i++)
    {
    temp=getch();
    if(temp == '\r')
    break;
    else
    {
    pword[i]=temp;
    putch('*');
    }

    }

    i would think that this would work, but... i get this instead:

    "_(password input)Password:"

    so Password: is displayed after i input it not before. So is there some sort of precedence that im missing and how can i fix it? Any ideas and or help is appreciated.

    - rootnix

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    do it like this.

    cout << "Password:" << flush;
    or
    cout << "Password:";
    cout.flush();
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    8
    no-one:
    thanks for your help can you do me a favor and explain what that does? i dont mean anything negative but i would like to learn it instead of memorize it. thank you

    - rootnix

  4. #4
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    well i'll try.

    What flush does basically is force whatevers in the stream to print immediatly instead of waiting for whatever it waits for.

    does that help or just confuse you more?
    feel free to ask if i can answer it i will.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    8
    yes that helps thank you, thats what i thought it did but i just wanted to make sure. thanks again

    - rootnix

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  2. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. Question about linked lists.
    By cheeisme123 in forum C++ Programming
    Replies: 6
    Last Post: 02-25-2003, 01:36 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM