TerranFury,
Kick ass!!! Very elegant. It works great.
Here is a section of the code where I incorporated your technique with what I am trying to accomplish:
------------------------------------------------------{ bool veri = false; string uKeyA, uKeyB, strOpt; do { int tmpCh = 0; uKsize = 0; cout << "\nEnter a password (32 chars. max.): "; while ((tmpCh = getch()) != 13) uKeyA += tmpCh; cin.clear(); uKsize = uKeyA.size(); if (uKsize > maxKeySIZE) { veri = false;uKeyA.erase(uKeyA.begin(), uKeyA.end());} cout << "\n\nEnter that password one more time: "; while ((tmpCh = getch()) != 13) uKeyB += tmpCh; cin.clear(); if (uKeyA == uKeyB) { veri = true; for (int i = 0; i < uKsize; ++i) key = uKeyA; <br> }<br><br> else<br> {<br> veri = false;<br> uKeyA.erase(uKeyA.begin(), uKeyA.end());<br> uKeyB.erase(uKeyB.begin(), uKeyB.end());<br><br> cout << "\n\nPassword does not match! Try again."<br>————————————————————-<br> </pre> <br><br>Note: I left some part of it out.<br><br>How did you determine integer 13 represents Enter or "\n?" Did you use:<br><br>cout << int("\n");<br><br>I am also trying to implement something like astrisks for each character like in windows. I am confident I can get that done. The code you post is simple, yet effectively.<br>—————-<br><br>Oluseyi:<br><br>Interesting. I think he used NULL to end the string, not to indicate a new line.<br>—————-<br><br>Lastly, here is a simple character array:<br><br>char temp[5] = {'a','b','c','d');<br><br>It is a rule that the last space has to be NULL? I think it is true if the program sends temp to cout. However, what if temp is used only as a storage variable? Is:<br><br>temp[4] = NULL;<br><br>required?<br><br>Kuphryn<br> </i> <br><br>Edited by - kuphryn on December 16, 2001 2:21:06 PM