[C/C++]warning: format '%c' expects argument of type 'char*', but argument 2 has type 'int' [-Wforma
2014-05-28 16:26
615 查看
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里面用的是地址,不是变量名
其调用形式为: scanf("<格式说明字符串>",<变量地址>);变量地址要求有效,并且与格式说明的次序一致。
相关文章推荐
- inet_ntoa warning: format '%s' expects type 'char *', but argument 2 has type 'int'
- jni编译时出现:warning: format '%d' expects argument of type 'int', but argument 4 has
- warning: format ‘%s’ expects argument of type ‘char *’和warning: backslash and newline separated by
- Argument of type '(Foo::)(int,int)' does not match 'void (*)(int,int)'以及静态函数问题
- g++编译报错原因分析 format ?.d?.expects argument of type ?.nt?. but argument 3 has type ?.
- inet_ntoa编译提示警告: 格式 ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]
- argument of type 'void (main form::)()' does not match 'void (*)(int)'
- Ubuntu gcc编译报错:format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘__time_t’ [-Wformat=]
- linux c之提示format‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat
- warning: passing argument 2 of 'request_irq' from incompatible pointer type导致的中断申请失败和
- (c++) Passing `const' as `this' argument of `' discards qualifiers
- 闭包错误-Cannot invoke 'responseResult' with an argument list of type
- variable 'std:ofstream' has initializer but incomplete type 错误
- error: ISO C++ forbids declaration of 'XXXX' with no type
- Bean property 'esyerDao' is not writable or has an invalid setter method. Does the parameter type of
- warning: no rule to process file 'h' of type sourcecode.c.h for architecture i386
- Bean property 'RegDao' is not writable or has an invalid setter method. Does the parameter type of t
- 两个C++编译错误及解决办法--does not name a type和field `XX' has incomplete type
- 两个C++编译错误及解决办法--does not name a type和field `XX' has incomplete type
- 解决cast from 'char*' to 'char**' increases required alignment of target type [-Werror=cast-align]