ä¸é¢æ¯æå¨ubuntu10.10ä¸åçï¼å·²ç»éªè¯è¿ï¼å¯ä»¥æ»¡è¶³ä½ é¢ç®çè¦æ±ï¼ç¨åºåé¢çæ°åæ¯è¡å·ï¼æ³¨æå»æã楼主è¿æä»ä¹ä¸æçå¯ä»¥é®æãqqï¼759019038
1 #include<stdio.h>
2 #include<string.h>
3 int main()
4 {
5 char name[20] = "tom";//æ£ç¡®çç¨æ·å
6 char password[20] = "abcdef";//æ£ç¡®çå¯ç
7 int i = 0;//è®°å½å¾ªç¯ç次æ°
8 char input_name[20],input_password[20];//ç¨æ·è¾å
¥çç¨æ·ååå¯ç
9 while(i<3){
10 printf("please input your name:");
11 scanf("%s",input_name);
12 printf("please input your password:");
13 scanf("%s",input_password);
14 /*注æå符串çæ¯è¾ç¨strcmp()å½æ°*/
15 if(strcmp(name,input_name)==0&&strcmp(password,input_password)==0){
16 printf("welcome!!!\n");
17 break;
18 }else
19 i++;
20 if(i<2)
21 printf("error username or password!please input again!\n");
22 if(i>2)
23 printf("you can`t input again!Goodbye!!!\n");
24 }
25 return 0;
26 }
温馨提示:答案为网友推荐,仅供参考