當前位置:編程學習大全網 - 網站源碼 - C語言編寫壹個用戶登陸的程序?

C語言編寫壹個用戶登陸的程序?

代碼如下:

#include<stdio.h>

#pragma warning(disable:4996)

#include<string.h>

int main()

{

int i = 0;

char password[10] = { 0 };

printf("請輸入密碼:");

while (i < 3)

{

scanf("%s", password);

printf("\n");

if (strcmp(password, "972816") == 0)

{

printf("登錄成功\n");

break;

}

else

{

i++;

if (i != 3)

printf("再輸入壹次");

}

}

if (i == 3)

printf("密碼錯誤三次退出登錄界面\n");

system("pause");

return 0;

擴展資料:

#include後面有兩種方式,<>;和""前者先在標準庫中查找,查找不到在path中查找。後者為文件路徑,若直接是文件名則在項目根目錄下查找。

引用方法:#include?<stdio.h>

註意事項:在TC2.0中,允許不引用此頭文件而直接調用其中的函數,但這種做法是不標準的。也不建議這樣做。以避免出現在其他IDE中無法編譯或執行的問題。

百度百科—include

百度百科—stdio.h

  • 上一篇:如何使用jquery
  • 下一篇:誌願者貴州源代碼
  • copyright 2024編程學習大全網