use scan code of enter insted of ''\n'. which is 13 for enter. i will help you. while (getch()!=13)
Regards Abuzer Mughal On Fri, Mar 5, 2010 at 2:48 PM, Mohd Arif <myinf...@yahoo.com> wrote: > > > Use \r instead \n > > Thanks & Regards > > Mohammad Arif > > > > > > > > ________________________________ > From: Jalpan Randeri <jalpan3...@yahoo.com <jalpan3990%40yahoo.com>> > To: c-prog@yahoogroups.com <c-prog%40yahoogroups.com> > Sent: Fri, March 5, 2010 12:17:51 AM > Subject: [c-prog] (unknown) > > > i was working on the program that will take username and password from > user... > > now i wanted show * on every key press in password menu/... > thats y i use the getch() function... > my code looks like this... > here i give the whole code.. > > ============ ========= ========= ========= ========= = > #include <iostream.h> > #include<fstream. h> > #include<stdio. h> > #include<conio. h> > #include<string. h> > > int main () > { clrscr(); > cout <<endl<< "Enter your username :"; > char user[10]; > cin>>user; > cout << "Enter you password: " ; > char pass[20]; > int i=0; > while(ch[i]! ='\n') ( "here is my problem occures it doesnt exit when i > press enter key.") > { > ch[i]=getch( ); > cout << " * " ; > i++; > } > ifstream OpenFile ("user.txt") ; > char user_saved[10] ; > char ch; > int i=0; > while (OpenFile.eof( )!=0) > { > OpenFile.get( user_saved[ i]); > i++ ; > } > OpenFile.close( ); > ifstream OpenFile1 ("pass.txt") ; > char pass_saved[20] ; > i=0; > while(OpenFile1. eof()!=0) > { > OpenFile1.get( pass_saved[ i]); > i++; > } > OpenFile1.close( ); > cout<< pass<<"password enterd"<<endl; > cout<<pass_saved< <"password saved"<<endl; > int user1,pass1; > pass1= strcmp(pass, pass_saved) ; > user1= strcmp(user, user_saved) ; > > cout << pass1 << "pass1"<<endl; > cout << user1 << "user1"<<endl; > if(user1==0 && pass1==0) > cout<<endl<< "login sucessful"; > else > cout<<endl<< "username or password is invalid"; > > getch(); > return 0; > } > > ------------ --------- --------- --------- --------- --------- - > > DoN't let anyoNe steAl yoUr dreAm. > It's yoUr dreAm, not theiRs. > > with Regrads... > JalpAn RandeRi > > The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. > http://in.yahoo. com/ > > [Non-text portions of this message have been removed] > > [Non-text portions of this message have been removed] > > > [Non-text portions of this message have been removed]