na dann zeig doch mal her ^__^
--
Nunja, ich werds gleich editieren..aber die Lösung ist ganz eifnach: gegebenenfalls am ende das Zeihen mit einer \0 Überschreiben...^^" Code: string input::userinput(int passchar = 0) { /* Maximal 90 Zeichen! */ cout<<"Bitte geben sie hier iher gewuenschten Werte ein:"<<endl; int currentkeyvalue; string currentstring; int goback; int end = 0; while(end != 1) { //Solange end != 1 ;D if(kbhit()) //Wird eine Taste gedrückt? { currentkeyvalue = getch(); //Aktuellen Keywert in currentkeyvalue schreiben if(currentkeyvalue == 13) { //Return cout<<"\r"; end = 1; } else if(currentkeyvalue == 8) //Backspace { if(currentstring.length() >= 1) { currentstring.erase(currentstring.length()-1, 1); } goback = 1; } else if(currentkeyvalue == 10) { cout<<"\a"; } else { currentstring += currentkeyvalue; } if(passchar != 1) { cout<<"\r"<<(string) currentstring; } else { cout<<"\r"; for(int i=0;i<currentstring.length();i++) { cout<<"*"; } } if(goback==1) { if(currentstring.length() > 0) { cout<<" \b\r"; } else { cout<<"\a\r"; } goback = 0; } } } cout<<"\r"; for(int i=0;i++;i<currentstring.length()) { cout<<"\0"; } cout<<"\n"; return (string) currentstring; }
string input::userinput(int passchar = 0) { /* Maximal 90 Zeichen! */ cout<<"Bitte geben sie hier iher gewuenschten Werte ein:"<<endl; int currentkeyvalue; string currentstring; int goback; int end = 0; while(end != 1) { //Solange end != 1 ;D if(kbhit()) //Wird eine Taste gedrückt? { currentkeyvalue = getch(); //Aktuellen Keywert in currentkeyvalue schreiben if(currentkeyvalue == 13) { //Return cout<<"\r"; end = 1; } else if(currentkeyvalue == 8) //Backspace { if(currentstring.length() >= 1) { currentstring.erase(currentstring.length()-1, 1); } goback = 1; } else if(currentkeyvalue == 10) { cout<<"\a"; } else { currentstring += currentkeyvalue; } if(passchar != 1) { cout<<"\r"<<(string) currentstring; } else { cout<<"\r"; for(int i=0;i<currentstring.length();i++) { cout<<"*"; } } if(goback==1) { if(currentstring.length() > 0) { cout<<" \b\r"; } else { cout<<"\a\r"; } goback = 0; } } } cout<<"\r"; for(int i=0;i++;i<currentstring.length()) { cout<<"\0"; } cout<<"\n"; return (string) currentstring; }
--McSecu(Momentan offline) www.mcsecu.net Ich grüß das Atelier, das QFrat, und die Programmierforen.
Foren-Regeln