delete the empty function: the input contact name to find the appropriate data and delete data (contact has saved to file) are not learning linked list, cannot use the list to delete

CodePudding user response:
Suggest the original poster posted all codeCodePudding user response:
#include
#include
#include
#include
20 # define M
Struct conect//structure
{
Char name [11].
Char telnum [12].//phone number
Char address [100].//address
Int f;//tag
};
Int N=0;//the total number of global variables
int n;
int num;//the total number of
Struct conect c [10];//structure number
Struct conect cc;
Int main (void)
{
Void input (), expl (), meun (), password (), save (), read (), serch (), dele (), dele_all ();
Void dele_menu (), newsave ();
Void dele_save (); Part//delete function
Int choice;
//password ();
system("pause");
system("cls");
While (1)
{
Meun ();
Printf (" \ \ t \ \ t \ \ t t t t ");
The scanf (" % d ", & amp; Choice);
The switch (choice)
{
Case 1: input (); break;
Case 2: expl (); break;
Case 3: save (); break;
Case 4: read (); break;
Case 5: serch (); break;
Case 6: dele_menu (); break;
Case 7: newsave (); break;
Case: 0 exit (0);
}
printf("\n");
system("pause");//pause function
system("cls");//screen clearing function
}
}
Void input ()//input data function
{
int i;
Printf (" \ \ t \ \ t \ \ t t t t input number: ");
The scanf (" % d ", & amp; Num);
N=n;
For (I=N; i
Printf (" \ \ t \ \ t \ \ t t t t name: ");
The scanf (" % s ", c [I] name);
Printf (" \ \ t \ \ t \ \ t t t t call: ");
The scanf (" % s ", c [I] telnum);
Printf (" \ \ t \ \ t \ \ t t t t address: ");
The rewind (stdin);
Gets (c [I] address);
Printf (" \ \ t \ \ t \ \ t t t t tags: ");
The scanf (" % d ", & amp; C [I] f);
printf("\n");
N++;
}
}
Void expl reading input to preserve information ()//(timeliness)
{
int i;
12 12 printf (" % s % s % 30 s % s \ n ", "name", "phone", "address", "label");
for (i=0; i
12 12 printf (" % s % s % s "30, [I] c name, c [I] telnum, c [I] address);
The switch (c [I] f)
{
Case 1: printf (" relatives \ n "); break;
Case 2: printf (" colleagues \ n "); break;
Case 3: printf (" friends \ n "); break;
}
}
}
Void meun ()
{
Printf (" \ \ \ t \ \ t t t t \ t1 input contact \ n ");
Printf (" \ \ \ t \ \ t t t t \ t2 browse contacts \ n ");
Printf (" \ \ \ t \ \ t t t t \ t3 to save the contact \ n ");
Printf (" \ \ \ t \ \ t t t t \ t4 read from file \ n ");
Printf (" \ \ \ t \ \ t t t t \ t5 locate contacts \ n ");
Printf (" \ \ \ t \ \ t t t t \ t6 delete contacts \ n ");
Printf (" \ \ \ t \ \ t t t t \ t7 has new file \ n ");
Printf (" \ \ \ t \ \ t t t t \ t0 exit \ n ");
Printf (" \ \ t \ \ t \ \ t t t t please enter 1 or 2 \ n ");
}
Void dele_menu ()
{
int a;
Printf (" \ \ \ t \ \ t t t t \ t1 delete not to save the contact \ n ");
Printf (" \ \ \ t \ \ t t t t \ t2 delete saved contacts \ n ");
Printf (" \ \ \ t \ \ t t t t \ t3. Delete all contacts \ n ");
The scanf (" % d ", & amp; A);
The switch (a)
{
Case 1: dele (); break;
Case 2: dele_save (); break;
Case 3: dele_all (); break;
Default:
break;
}
}
Void password ()
{
Char password [10]="123456";//the correct password
Char ps [10];//define a new array with the right answer comparing
int i,j;
printf("\n\n");
Printf (" \ \ t \ \ t \ \ t t t t================================\ n ");
Printf (" \ \ t \ \ t \ \ t t t t user login system \ n ");
Printf (" \ \ t \ \ t \ \ t t t t================================\ n ");
printf("\n\n");
for (j=0; j <4. J++)
{
I=0;
Printf (" \ \ t \ \ t \ \ t t t t, please enter the password. \ n ");
Printf (" \ \ t \ \ t \ \ t t t t password: ");
While ((ps [I]=getch ())!=13)//used to replace *, input end of the enter judgment
{
If (ps [I]=='\ b')//(\ b) back space, here is used to delete functions
{
Printf (" \ \ b b ");//delete function
I -;//back to reduce a cursor in advance
}
The else
{
Printf (" * ");
i++;
}
}
Ps [I]='\ 0';
printf("\n");
If (STRCMP (password, ps)==0)
{
printf("\n\n");
Printf (" \ \ t \ \ t \ \ t t t t================================\ n ");
Printf (" \ \ t \ \ t \ \ t t t t welcome users! \n");
Printf (" \ \ t \ \ t \ \ t t t t================================\ n ");
printf("\n\n");
break;
}
The else
{
Printf (" \ \ \ t \ \ t t t t \ tNO! \n");
If (3 - j==0)
{
Printf (" \ \ t \ \ t \ \ t t t t all errors automatically quit!" );
exit(0);
}
Printf (" \ \ t \ \ t \ \ t t t t and % d chance! \ n ", 3 - j);
}
}
}
Void the save ()//store content function
{
The FILE * fp.
Int * a;
int i;
Fp=fopen (" conect. Dat ", "wb");//set up a file and open writing class capacity
for (i=0; i
Fwrite (& amp; C [I], sizeof (struct conect), 1, fp);//write file block
}
fclose(fp);//close the file
Printf (" \ n save success ");
}
Void the read ()//class let read function
{
FILE *fp;//pointer variable definition of
int i;
Fp=fopen (" conect. Dat ", "ab +");//set up a file and open writing class capacity
12 12 printf (" % s % s % 30 s % s \ n ", "name", "phone", "address", "label");
While (1)
{
Fread (& amp; Cc, sizeof (struct conect), 1, fp);//read the file blocks
If (feof (fp))//file end of end mark
{
break;
}
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull