<> Are you still worried about not remembering your account number ?
<> Are you still racking your brains for forgetting the password ?
<> as long as 998!!! Account management system to take home
Let's get to the point :
Privacy account management system :
1 requirement analysis : Record and protect personal account information , It has achieved the purpose of recording and inquiring at any time .
1.1 Questions raised : Plan to write a privacy information management system , It is mainly used to manage privacy information .
1.2 Knowledge points of the system design : function , structural morphology , file , loop , branch , Arrays, etc .
1.3 Functional requirements :
1) Establish the number of each account , Account location , Account description , Account name and password
2) Modify account information
3) Delete account information
4) Query account information , It is divided into search by part of account name and search by number
5) Output all account information
6) Exit the program
2 overall design
2.1 functional design :
1) Program password verification function : The following program appears at the beginning of the program , To prevent forgetting the initial password , The default password is built into the code , by 110120, It can be modified by oneself .
2) utilize switch Main menu of sentence design :
------ Privacy information management system ------ 1. Account information entry 2. Account information modification 3. Delete account information 4. Query account information 5. Output all account information 6.
sign out Please select (1-6):
3) Design Branch : Press 4 It will appear later
------ Query menu ------ Please enter the option number (1~2) 1---- Query by number 2---- Query by partial account name
There are two ways to query account specific information
4) Function function
int Verification();// Program password verification function int Mess_SearchByIndex(int id);// Find account information by number void
Mess_Find();// Find the account information through the number and output it void Mess_DisplaySingle(int index); // Output information of corresponding number void
Mess_Insert();// Add account information void Mess_Modify();// Modify account information void Mess_Delete();// Delete account information
void Mess_Select();// Query account information through partial account information void Mess_Display();// Output all account information void
IO_ReadInfo();// Read out the document void IO_WriteInfo();// Read in file
3 detailed design :
3.1 Module function description : It is mainly divided into establishment , modify , delete , query , Output four big modules
3.1.1: Building a module :
Function prototype :void Mess_Insert().
function : Enter the number of the planned account , Account location , Account description , Account name , password , And the password is encrypted .
input : Input according to the corresponding prompt
3.1.2: Modify module :
Function prototype :void Mess_Modify().
function : Block to modify the account information of the corresponding number
input : Enter the account number of the information you want to modify
3.1.2: Query module :
Function prototype 1:void Mess_Select();
function : Search part of the input account information
Function prototype 2:void Mess_Find();
function : Search the entered account number
input : Select one of the two corresponding input
3.1.2: output module :
Function prototype :void Mess_Display().
function : Detailed information output for all recorded accounts
input : nothing
5 test :
Enter program password , Access privacy information management system
Enter two account information :
Output all account information :
And query :
Exit the program :
Run the program again next time , The previously saved account information still exists :
<> Important note :
This code needs to be in the c Create one under the disk message.txt file , Used to store data , All account information is stored here in binary form , You don't have to worry about password leaks , Because a simple password encryption program is set in the program , The stored password is encrypted , You can also modify the encryption method in the code , Here's a simple code ASCII code +48 Stored , I added it when I read it out 48
<> usage method
1) Build one txt Document save data
2) Put a running program of the code on the desktop , Source code self preservation
3) Remember to press the 6 Normal exit , You can't close the running window directly
4) Protect it txt file , Do not modify the contents
<> Source code appendix :
#include <stdio.h> #include <stdlib.h> #include <string.h> struct Mess { int No
; char place[50]; char describe[50]; char name[50]; char code[50]; }mess[1000];
int Verification();// Program password verification function int Mess_SearchByIndex(int id);// Find account information by number void
Mess_Find();// Find the account information through the number and output it void Mess_DisplaySingle(int index); // Output information of corresponding number void
Mess_Insert();// Add account information void Mess_Modify();// Modify account information void Mess_Delete();// Delete account information
void Mess_Select();// Query account information through partial account information void Mess_Display();// Output all account information void
IO_ReadInfo();// Read out the document void IO_WriteInfo();// Read in file int num=0; int Verification() {
int i; char inkey[20]; printf("------ Program password verification ------\n Please input a password :"); for(i=1;i<=3;i++) {
scanf("%s",inkey); if(strcmp(inkey,"110120")==0) break; else printf(
"\n Wrong password , also %d Second chance \n",3-i); } if(i==4) { printf("3 Wrong input , Exit the program \n"); return 0; } else
{ printf(" The input is correct , Access privacy information management system \n"); return 1; } } int Mess_SearchByIndex(int id) {
int i; for (i=0;i<num;i++) { if (mess[i].No==id) { return i; } } return -1; }
void Mess_Find() { int id; while(1) { printf(" Enter the number of the account you want to find :"); scanf("%d",&id);
getchar(); Mess_DisplaySingle(Mess_SearchByIndex(id)); printf(" Continue to query ?(y/n)");
if (getchar()=='n') { break; } } } int Mess_SearchByName(char name[]) { int i;
for (i=0;i<num;i++) { if (strstr(mess[i].name,name)) { return i; } } return -1;
} void Mess_DisplaySingle(int index) { char str[20]; for(int i=0;i<strlen(mess[
index].code);i++) { str[i]=mess[index].code[i]-48; } str[strlen(mess[index].code
)]='\0'; printf("%-5s%-25s%-20s%-18s%-10s\n"," number "," Account location "," Account description "," Account name "," password ");
printf(
"-------------------------------------------------------------------------\n");
printf("%-5d%-25s%-20s%-18s%-10s\n",mess[index].No,mess[index].place, mess[index
].describe,mess[index].name,str); } void Mess_Insert() { while(1) { printf(
" Please enter the number :"); scanf("%d",&mess[num].No); getchar(); printf(" Please enter account location :"); scanf("%s",
&mess[num].place); getchar(); printf(" Please enter account description :"); scanf("%s",&mess[num].describe
); getchar(); printf(" Please enter the account name :"); scanf("%s",&mess[num].name); getchar(); printf(
" Please input a password :"); char str[20]; scanf("%s",&str); getchar(); int i; for(i=0;i<strlen(
str);i++) mess[num].code[i]=str[i]+48; mess[num].code[i]='\0';
Mess_DisplaySingle(num); num++; printf(" Do you want to continue ?(y/n)"); if (getchar()=='n') {
break; } } } void Mess_Modify() { while(1) { int id; int index; printf(
" Please enter the number of the information to be modified :"); scanf("%d",&id); getchar(); index=Mess_SearchByIndex(id); if (
index==-1) { printf(" Account does not exist !\n"); } else { printf(" The privacy information you want to modify is :\n");
Mess_DisplaySingle(index); printf("-- Please enter a new value --\n"); printf(" Please enter the number :"); scanf("%d",
&mess[index].No); getchar(); printf(" Please enter account location :"); scanf("%s",&mess[index].place);
getchar(); printf(" Please enter the account name :"); scanf("%s",&mess[index].name); getchar(); printf(
" Please input a password :"); char str[20]; scanf("%s",&str); getchar(); int i; for(i=0;i<strlen(
str);i++) mess[index].code[i]=str[i]+48; mess[num].code[i]='\0'; } printf(
" Do you want to continue ?(y/n)"); if (getchar()=='n') { break; } } } void Mess_Delete() { int i;
while(1) { int id; int index; printf(" Please enter the number of the information you want to delete :"); scanf("%d",&id); getchar()
; index=Mess_SearchByIndex(id); if (index==-1) { printf(" Account does not exist !\n"); } else {
printf(" The account information you want to delete is :\n"); Mess_DisplaySingle(index); printf(" Are you sure you want to delete ?(y/n)"); if
(getchar()=='y') { for (i=index;i<num-1;i++) { mess[i]=mess[i+1];// Move the objects in the back forward }
num--; } getchar(); } printf(" Do you want to continue ?(y/n)"); if (getchar()=='n') { break; } } }
void Mess_Select() { while(1) { char name[20]; int index; printf(
" Please input part of the information of the account you want to query :"); scanf("%s",&name); getchar(); index=Mess_SearchByName(name);
if (index==-1) { printf(" Account does not exist !\n"); } else { printf(" The account information you want to query is :\n");
Mess_DisplaySingle(index); } printf(" Do you want to continue ?(y/n)"); if (getchar()=='n') { break;
} } } void Mess_Display() { int i; while(1) { printf(
"%-5s%-25s%-20s%-18s%-10s\n"," number "," Account location "," Account description "," Account name "," password "); printf(
"-------------------------------------------------------------------------\n");
for(int j=0;j<num;j++) { char str[20]; for(int i=0;i<strlen(mess[j].code);i++) {
str[i]=mess[j].code[i]-48; } str[strlen(mess[j].code)]='\0'; printf(
"%-5d%-25s%-20s%-18s%-10s\n",mess[j].No,mess[j].place, mess[j].describe,mess[j].
name,str); } break; } } void IO_ReadInfo() { FILE *fp; int i; if ((fp=fopen(
"c:\\message.txt","rb"))==NULL)// Learn the file here can modify the path { printf(" Unable to open file !\n"); return;
} if (fread(&num,sizeof(int),1,fp)!=1) { num=1; } else { for(i=0;i<num;i++) {
fread(&mess[i],sizeof(struct Mess),1,fp); } } num=0; fclose(fp); } void
IO_WriteInfo() { FILE *fp; int i; if ((fp=fopen("c:\\message.txt","wb"))==NULL)
// Learn the file here can modify the path { printf(" Unable to open file !\n"); return; } if (fwrite(&num,sizeof(int),1
,fp)!=1) { printf(" Write file error !\n"); } for (i=0;i<num;i++) { if (fwrite(&mess[i],
sizeof(struct Mess),1,fp)!=1) { printf(" Write file error !\n"); } } fclose(fp); } int main(
) { if(!Verification()) return 0; int choice; IO_ReadInfo(); while(1) { /* Main menu */
printf("\n------ Privacy information management system ------\n"); printf("1. Account information entry \n"); printf("2. Account information modification \n"
); printf("3. Delete account information \n"); printf("4. Query account information \n"); printf("5. Output all account information \n"); printf
("6. sign out \n"); printf(" Please select (1-6):"); scanf("%d",&choice); getchar(); switch(choice)
{ case 1: Mess_Insert(); break; case 2: Mess_Modify(); break; case 3:
Mess_Delete(); break; case 4: printf("------ Query menu ------\n"); printf(
" Please enter the option number (1~2)\n"); printf("1---- Query by number \n"); printf("2---- Query by partial account name \n"); int k;
scanf("%d",&k); getchar (); switch(k) { case 1:Mess_Find();break; case 2:
Mess_Select();break; } break; case 5: Mess_Display(); break; case 6: return 0;
break; } IO_WriteInfo(); } return 0; }
Technology