int Add(ZGGZ tp[],int n)
{
char ch ,num[10];
int i,flag=0;//flag 标记是否已经存在
system("cls");
if(flag == 0)
{
printf("sorry, %s is already exist,try again? Y/N?",num);
scanf("%c",ch);
if (ch == 'Y'|| ch == 'y')
continue;
else return n;
编译后错误信息提示:
SalaryManager.cpp|180|warning: format '%c' expects argument of type 'char*', but argument 2 has type 'int' [-Wformat]|
解决办法:
scanf("%c",&ch);
原因:scanf里面用的是地址,不是变量名
intscanf(constchar*format,...);
|
其调用形式为: scanf("<格式说明字符串>",<变量地址>);变量地址要求有效,并且与格式说明的次序一致。