Home > Back-end >  Run shows that there are any errors, please noted
Run shows that there are any errors, please noted

Time:09-21

//address book, query, modify, delete and display program 
#include
#include
#include
int count=0;
Char * NAME [30]
Struct ml
{
Char name [10].
Char sex;
int age;
Char num [10].
Char phone [20].
};
//the new contact
Void dnew (struct ml friends [])
{
Struct ml x;
If (count==30)
{
Printf (" directory is full ");
return;
}
Printf (" please enter a new contact name ");
The scanf (" % s ", x.n ame);
Printf (" please enter a new contact gender ");
The scanf (" % c ", x.s ex);
Printf (" please enter a new contact age ");
The scanf (" % d ", x.a ge);
Printf (" please enter a new contact class ");
The scanf (" % s ", x.n um);
Printf (" please enter a new contact phone number ");
The scanf (" % s ", x.p hone);
printf("\n");
Friends [count]=x;
count++;
}
//modify contact
Void edit (struct ml friends [], char * name)
{
Int I, j, k, a=0;
Struct ml x;
for(i=0; i{
If (STRCMP (name, friends [I] name)==0)
{
A=1;
break;
}
}
If (a==1)
{
Printf (" please input the name of the modified \ n ");
The scanf (" % s ", x.n ame);
Printf (" please enter the sex of the modified \ n ");
The scanf (" % c ", x.s ex);
Printf (" please enter the age of the modified \ n ");
The scanf (" % d ", x.a ge);
Printf (" please input the modified class \ n ");
The scanf (" % s ", x.n um);
Printf (" please enter the modified contact phone number ");
The scanf (" % s ", x.p hone);
Friends [I]=x;
The NAME [I]=friends [I]. NAME;
for(i=0; i{
k=i;
For (j=I + 1; J{
If (STRCMP (NAME [I], the NAME [j]) & gt; 0)
K=j;
}
If (k!=I);
{x=friends [I]; Friends [I]=friends [k]. Friends [k]=x; }
}
}
The else
Printf (" this free contact! \n");
}
//query the contact
Void search (struct ml friends [], char * name)
{
Int I, flag=0;
If (count==0)
{
Printf (" address book is empty ");
return;
}
for(i=0; i{
If (STRCMP (name, friends [I] name)==0)
{
Flag=1;
Printf (" \ t name: % s ", friends [I] name);
Printf (" surname don't: % \ t c, "friends [I] sex);
Printf (" age: % d \ t, "friends [I] age);
Printf (" \ t "class: % s, friends [I] num);
Printf (" contact phone: % s \ t, "friends [I] phone);
}
}
If (flag<1)
Printf (" this free contact! \n");
}
//delete contact
Void does (struct ml friends [], char * name)
{
Int I, j, flag=0;
for(i=0; i{
If (STRCMP (name, friends [I] name)==0)
{
Flag=1;
break;
}
}
If (flag=1)
{
For (j=I; JFriends [j]=friends [j + 1);
The count -;
}
The else
Printf (" no contact "");
Printf (" contacts deleted ");
}
//display all contacts
Void sort (struct ml friends [])
{
int i;
If (count==0)
{
Printf (" address book is empty! \n");
return;
}
The else
{
Printf (" in alphabetical order: \ n ");
for(i=0; i{
Printf (" \ t name: % s ", friends [I] name);
Printf (" surname don't: % \ t c, "friends [I] sex);
Printf (" age: % d \ t, "friends [I] age);
Printf (" \ t "class: % s, friends [I] num);
Printf (" contact phone: % s \ t, "friends [I] phone);
}
}
}
//the main function
Int main ()
{
Char choice;
Char name [10].
Struct ml friends [30].
Do
{
Printf (" * * * * * * address book function * * * * * * \ n ");
Printf (" 1: the new \ n ");
Printf (" 2: modify \ n ");
Printf (" 3: query \ n ");
Printf (" 4: delete \ n ");
Printf (" 5: display \ n ");
Printf (" 0: exit \ n ");
Printf (" please select a number: ");
The scanf (" % d ", & amp; Choice);
The switch (choice)
{
Case 1: dnew (friends);
break;
Case 2:
Printf (" please input to change the names of the people: ");
The scanf (" % s ", name);
Edit (friends, name);
break;
Case 3:
Printf (" please enter to check out the names of the people: ");
The scanf (" % s ", name);
Search (friends, name);
break;
Case 4:
Printf (" please input want to delete the names of the people: ");
The scanf (" % s ", name);
Does (friends, name);
break;
Case 5:
Sort (friends);
break;
Case 0:
break;
}
} while (choice!=0);
Printf (" thanks to use the address book management system! \n");
return 0;
}




This is a vc + + to point out mistakes, a bit don't understand the


1> -- -- -- -- -- - has started to generate: project: hair, configuration: Debug Win32 -- -- -- -- -- --
1> C
MC.1> C: \ users \ \ documents \ visual studio 11582 2010 \ projects \ \ hair \ MC c (8) : error C2054: after "the NAME" should input "("
1> C: \ users \ \ documents \ visual studio 11582 2010 \ projects \ \ hair \ MC c (9) : error C2057: constant expression should be input
1> C: \ users \ \ documents \ visual studio 11582 2010 hair \ projects \ \ \ MC c (10) : error C2229: struct "ml" has the size of the illegal zero array
1> C: \ users \ \ documents \ visual studio 11582 2010 \ projects \ \ hair \ MC c (12) : error C2057: constant expression should be input
1> C: \ users \ \ documents \ visual studio 11582 2010 \ projects \ \ hair \ MC (13) c: error C2057: constant expression should be input
1> C: \ users \ \ documents \ visual studio 11582 2010 hair \ projects \ \ \ MC (13) c: error C2229: struct "ml" has the size of the illegal zero array
1> C: \ users \ \ documents \ visual studio 11582 2010 hair \ projects \ \ \ MC c (16) : error C2233: "friends" : contains an array of objects with zero size array is illegal
1> C: \ users \ \ documents \ visual studio 11582 2010 \ projects \ \ hair \ MC c (17) : error C2085: "dnew" : not parameter table
1> C: \ users \ \ documents \ visual studio 11582 2010 \ projects \ \ hair \ MC c (17) : error C2143: syntax errors: lack of ";" (in front of the "{")
1> nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related