Ich benötige einfachen Kennwort Script, Hilfe??
-
ich glaube ich hab's; ist es das:
sprech' mal 'Pö' aus mit scharfem P un dkurzem ö
ist es das?
-
freshman schrieb:
virtuell Realisticer schrieb:
Poeh!
Was heißt das?
Du koenntest es so verstehen:
realisticer sieht verachtend an freshman vorbei und geht, mit dem Gedanken im
Hinterkopf, dass man sich die Beziehung zwischen passwd im zweiten und dem im
ersten Post haette denken koennen, weiter:D.
Ok, ich denke das wird zu OT hier, hehe. Gibs zu fresh, du willst mich was
aergern *g*mfg
v R
-
OT==OverTrieben ??
fresh!=frech ??
außerdemist Freitag-Nachmittag, kurz vor Feierabend und da kann man eben nicht mehr so gut denken
-
freshman schrieb:
OT==OverTrieben ??
ne :), aber fuer dich: http://dnq.priggish.de/#charta
fresh!=frech ??
so langsam
außerdemist Freitag-Nachmittag, kurz vor Feierabend und da kann man eben nicht mehr so gut denken
Da stimme ich absolut zu ;).
mfg
v R
-
the script works good and I thank everyone here for helping me immensily.. so thank you immensily
However, I have another question, first here is my \1:
#include<iostream> #include<string> bool checkPasswd(const std::string &password) { std::string passwd = "0x042e"; if(password != passwd) return false; return true; } int main() { std::cout<<"Password: "; std::string userPasswd; std::getline(std::cin,userPasswd); if(checkPasswd(userPasswd)) std::cout<<"\nCorrect! Good job..\n"; else std::cout<<"\nWrong! Try again..\n"; return 0; }
my question is, in the event that someone is wrong, how can I have the script, first tell them they we're wrong, and then to go back to int main(), instead of exiting the app.??
Plus, while in the Visual Studio env. The app works great, but when I use it in my windows env. the app works but when it comes time to output either correct or wrong, it does not pause, but simply closes out.. any ideas why and how to fix these two things I request?? Thank you very much in advance
-
You can do it like this, for example:
int main() { for ( ; ; ) { std::cout<<"Password: "; std::string userPasswd; std::getline(std::cin,userPasswd); if(checkPasswd(userPasswd)) { std::cout<<"\nCorrect! Good job..\n"; break; } else std::cout<<"\nWrong! Try again..\n"; } // if you get here, the passwd was correct return 0; }
edit
The app just doesn't close while developing because vc++ prevents it from doing that.
You have to add some user input (cin.get() or something like that) at the end of your program if you want your console window to remain open.
-
thanks for the script, I actually worked it out by including conio.h and adding the getch(); function before the return 0; function..
-
3mu180r schrieb:
thanks for the script, I actually worked it out by including conio.h and adding the getch(); function before the return 0; function..
Note that conio.h and the functions defined within conio.h are not part of
the Standard-C++ Library. When you port the program to another platform where
conio.h isn't available then your program won't compile anymore.mfg
v R
-
@vR: It's right, there is a standard way to stop the program for keypress. But HumeSikkins said, that this code doesn't work on a few compilers. Maybe the non-standard way is the better one...
Best regards,
SideWinder
-
SideWinder schrieb:
@vR: It's right, there is a standard way to stop the program for keypress. But HumeSikkins said, that this code doesn't work on a few compilers. Maybe the non-standard way is the better one...
Best regards,
SideWinderHmmm...yes. For interested people, SideWinder refers to this thread:
http://www.c-plusplus.net/forum/viewtopic.php?t=80672&start=0&postdays=0&postorder=asc&highlight=In this thread hume posted:
HumeSikkins schrieb:
Und jetzt kommt das Tolle: In der Regel funktioniert die sync()-Variante nicht bei Implementationen bei denen die in_avail()-Variante funktioniert und andersherum funktioniert die in_avail()-Variante genau dort nicht, wo die sync()-Variante funktioniert.
Maybe a workaround could be this code
void clearCinInBuf() { if(cin.rdbuf()->in_avail()) { cin.clear(); cin.ignore(cin.rdbuf()->in_avail()); cin.get(); } else { cin.sync(); cin.get(); } }
mfg
v R