"Warning C6328 size does not match: have int [15]" as _Param_ (2), but you need to use the 32 bit "operand" to call "the scanf", this means that there may be a serious mistake, if for reporting this information, like the scanf function may said lack of buffer overflow, or practice 3 D: \ MYCSPACE \ chapter 12 3 \ \ practice contacts. C 130
This mistake how to solve ah==
(for the first time in CSDN to ask questions
CodePudding user response:
offer may need to codeCodePudding user response:
Post code directlyCodePudding user response:
/* * simple contacts management/
#include
#include
#include
#include
Typedef struct Address_Book {
char name[10];/* name */
Char company [20]./* */
Char position [10]./* * position/
Char group [20]. Group/* */
Int phone_num [15]./* */phone number
Int company_num [15]./* */office phone
Char Email [20];/* E-mail */
Char address [25];/* address */
} the same;
Void the StartWork ();/* contacts management system began to work to prepare */
Void EndWork ();/quit ready to * * contacts management system/
Void Storage ();/* */storage
Void Look_Up ();/* refer to */
Void To_Updata ();/* * update/
Void initiSystem (); Initialization/* */
The FILE * fp=NULL;
Void main ()
{
Char ch;
The StartWork ();
/* menu interface */
While (1)
{
system("cls");
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
Printf (" this program developed by C language waste their | | \ n ");
Printf (" | "* * * * * * * * * * | contacts management system \ n");
Printf (" | 1 -- -- -- -- -- -- -- -- -- - | store contact information \ n ");
Printf (" | 2 -- -- -- -- -- -- -- -- -- - | refer to the contact information \ n ");
Printf (" | 3 -- -- -- -- -- update contact information -- -- -- -- - | \ n ");
Printf (" | -- -- -- -- -- 4 initial contact information -- -- -- - | \ n ");
Printf (" | exit 5 -- -- -- -- -- -- -- -- -- -- -- -- - | \ n ");
Printf (" | -- -- -- -- -- - please select function - (1 ~ 5) | \ n ");
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
Ch=getchar ();
If (ch=='5')
{
Printf (" out "management system, thank you for your use! - \ n ");
break;
}
The switch (ch)
{
Case '1' : Storage (); break;
Case '2' : Look_Up (); break;
Case: '3' To_Updata (); break;
Case '4' : initiSystem (); break;
Default: printf (" the function of the input the wrong number! \n"); break;
}
Printf (" press any key to continue! \n");
getch();
fflush(stdin);
}
EndWork (fp);
}
/* contacts management system began to work to prepare */
Void the StartWork ()
{
The same contact;
Long len.
Fp=fopen (" Contact. Dat ", "rb +");
If (fp==NULL)
{
Printf (" can't open the file Contact dat! \n");
InitiSystem ();
Printf (" press any key to continue \ n ");
getch();
fflush(stdin);
}
The else
{
Fseek (fp, 0, SEEK_END);
Len=ftell (fp);
If (len & gt; Sizeof (same))
{
Fseek (fp, sizeof (same), SEEK_END);
Fread (& amp; Contact, sizeof (same), 1, fp);
}
Else if (len<0)
{
Printf (" operating system files failed! \n");
getch();
exit(1);
}
}
}
/quit ready to * * contacts management system/
Void EndWork ()
{
fclose(fp);
}
/* * initialization system/
Void initiSystem ()
{
If (fp!=NULL)
{
fclose(fp);
Remove (" Contact. Dat ");
}
Fp=fopen (" Contact. Dat ", "wb +");
If (fp==NULL)
{
Printf (" initialization failed! \n");
getch();
exit(1);
}
Printf (" the initial success! \n");
}
/* */store contact information
Void Storage ()
{
system("cls");
The same contact;
Printf (" -- -- -- -- -- -- -- -- -- -- * * * * * * * please enter information in turn * * * * * * * -- -- -- -- -- -- -- -- -- -- \ n ");
Printf (" - name - company units - position - group - office telephone - mobile phone - email - the address information \ n ");
The scanf (" % s ", & amp; Contact. Name);
The scanf (" % s ", & amp; Contact.com pany);
The scanf (" % s ", & amp; Contact. The position);
The scanf (" % s ", & amp; Contact. Group);
The scanf (" % d ", & amp; Contact.com pany_num);
The scanf (" % d ", & amp; Contact. Phone_num);
The scanf (" % s ", & amp; Contact. Email);
The scanf (" % s ", & amp; Contact. Address);
Fseek (fp, 0, SEEK_END);
Fwrite (& amp; Contact, sizeof (same), 1, fp);
Printf (" store contact % s success! . \ n ", contact name);
}
/* refer to */
Void Look_Up ()
{
Int no_total=0;
The same contact;
Same contact_Look_Up;
Printf (" please input information query that you want the contact name: ");//search by contact name
The scanf (" % s ", & amp; Contact_Look_Up. Name);
Fseek (fp, 0, SEEK_SET);
Fread (& amp; Contact, sizeof (same), 1, fp);
if (! The feof (fp))
{
If (STRCMP (contact name, contact_Look_Up name)==0)
{
No_total=1;
Printf (" - name - company units - position - group - office telephone - mobile phone - email - the address information \ n ");
- 8-10 printf (" % s % s % - 10 s % - 10 s % d % d % % - 20 s to 25 s \ n ", contact. The name, contact.com pany, contact, position and contact. The group, contact.com pany_num, contact the phone_num, contact, Email, contact, address).
}
Fread (& amp; Contact, sizeof (same), 1, fp);
}
If (no_total==0)
{
Printf (" could not find the contact person! \n");
}
}
/* * update/
Void To_Updata ()
{
Int no_total=0;
The same contact;
Same contact_To_Updata;
Char ch;
Printf (" please enter your updated contact person's name: ");
The scanf (" % s ", & amp; Contact_To_Updata. Name);
Fseek (fp, 0, SEEK_SET);
Fread (& amp; Contact, sizeof (same), 1, fp);
if (! The feof (fp))
{
If (STRCMP (contact name, contact_To_Updata name)==0)
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull