#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<Windows.h>
#include<conio.h>
int main(){
//welcome Heading
printf("\t\t\t``````````````````````````````````````````````````````````````\n");
printf("\t\t\t\tWelcome to The Bank Management System\n\n");
printf("\t\t\t``````````````````````````````````````````````````````````````\n\n");
//password input and validation
char pass[10],password[10]="pass";
int i;
printf("Please Enter Password....");
fflush(stdin);
gets(pass);
if (strcmp(pass,password)==0){
printf("WELCOME \nLoading");
for(i=0;i<5;i ){
printf(".");
Sleep(1000);
}
}
else{
printf("incorrect password");
getche();
system("tput clear");
system("cls");
system("clear");
main();
}
return 0;
}
如何在 C 編程中清除螢屏我是使用 dev c 的 U,但我嘗試的一切似乎都失敗了我已經包含了許多不同的庫,但似乎都沒有作業。
uj5u.com熱心網友回復:
您似乎正在使用conio.h。我建議閱讀它的檔案。如果您在其他地方找不到它,它可能可以從 Microsoft 下載。
對于清除螢屏,它具有clrscr()功能。使用它來清除螢屏。
請注意,您的代碼還有很多其他問題,包括:
- 永遠不要使用
gets(),使用例如。fgets. - 不要
main()遞回呼叫,使用回圈。 - 如果stdio.h不夠,不要使用conio.h,使用curses庫或直接 Windows Win32 API 呼叫。
- 避免使用
system()任何東西。 - 當您閱讀用戶輸入(或檔案)時,請始終檢查錯誤。
但是不要緊張,直到以后...
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/410349.html
標籤:
