程序代码:
#include < stdio.h > #include < string.h > #include < stdlib.h > void main( ) { char p[10]; char password []= "119"; // 定义为这种形式也行 char time = 0; while ( time <3 ){ printf( "Enter password:\n" ); scanf( "%s", p ); if( strcmp( p,password ) == 0 ){ printf( "OK,Welcome\n" ); break; } else time ++; } if( time == 3 ) printf( "Who are you ?" ); system( "pause" ); }