Move lines 29..32 before line 23. Think about why this makes a difference. BTW, why the special handling for space characters? That is, why cannot a space be part of the password?
Hope this helps.
Sir Duoas. Thanks for the reply. It is greatly appreciated. I am still new to C++ and do lack skills in logic building. I am really having a hard time read the flow of a program. Especially how you manipulate the variables and constants. Also, in putting conditions to a loop or if statement. I tried the one you said. My guess is that so the program will try to check the two spaces before it displays the mask. Now, with your question Sir. Since I am still on the learning process. Can I ask what is special handling for space characters is? and the space cannot be a part of the password as my professor gave us the problem that it should not be masked by asterisk. Actually, it is a part of the password. My professor just don't want it to be masked. I already tried this though:
And the problem with this one is the backspace key. What do you think about using escape sequences instead of ASCII codes? My classmates use it. I just don't want my professor to think that I just copied it from them. And I also don't what to develop the habit of copying other's work. I want to be better in my field of specialization. I'm going to need a lot of help and encouragement, I guess. And of course. Practice and Study. I really enjoy programming and It is my passion. I hope the people in this forum can help me. Thanks again Sir Duoas.
Using escape sequences is correct -- and they are part of the C standard -- so it is OK to use them.
Your first posting was closer to correct. The problem is that on lines 29-32 you don't add the key the user pressed (the space key) to the password. But on lines 23-28 you correctly add the key the user pressed to the password. You need to fix lines 29-32 to add the space key to the password also. Once done (and putting the lines 29-32 and lines 23-28 in the correct order like I first suggested) then your program should work just right.
BTW, you should get rid of those calls to system(). Your program should not be clearing the screen or PAUSE-ing.
One final note. I am not "Sir" Duoas -- in English that would mean that I were knighted, which I am not. http://en.wikipedia.org/wiki/Sir
Sorry for that Duoas. It is just a sign of respect. Never meant that I am referring to you as a knight. Would "Mister" be alright for you? I did what you have suggested. Thanks for that. Though, the space key still has a problem. It prints a space but also prints an asterisk. This is what I have done. Would you kindly check it for me? Thanks again. Midterms is coming. Sorry if I replied so late.