Saturday, May 22, 2010

Problem with Dev C++ coding?

code:


char passwd[10].


cout%26lt;%26lt;"Enter Password : ";


cin%26gt;%26gt;passwd;


output:


Enter Password : ___





when i enter password, screen looks like:


Enter Password : 786mc





But I want the screen looks like :


Enter Password : *****.





Is it possible in Dev C++ (bloodshed).

Problem with Dev C++ coding?
int i;


char password[10], temp;


clrscr( );





for( i = 0; i %26lt;= 10; i++ ) {


...temp = getch( );


...if( temp == 8 ) { // 8 : ASCII for backspace


......if( i == 0 ) { i--; }


......else {


.........gotoxy( wherex()-1, wherey() );


.........cout %26lt;%26lt; " ";


.........gotoxy( wherex()-1, wherey() );


.........password[i-1] = NULL;


.........i -= 2;


......}


...}


...else if( temp != 13 %26amp;%26amp; i == 10 ) { i--; } // 13: ASCII for Enter


...else if( temp == 13 ) { i = 10; }


...else {


......password[i] = temp;


......password[i+1] = NULL;


......cout %26lt;%26lt; "*";


...}


}





// Test if values are correct


cout %26lt;%26lt; endl %26lt;%26lt; endl %26lt;%26lt; password;
Reply:char passwd[10].


cout%26lt;%26lt;"Enter Password : ";


for (int i=0; i %26lt;10; i++;)


{


passwd=getch();


cout%26lt;%26lt;"*";


}

customer survey

No comments:

Post a Comment