【发布时间】:2016-04-14 19:49:36
【问题描述】:
当我尝试编译它时,我得到以下错误,不知道为什么......
警告:格式“%x”需要“unsigned int”类型的参数,但参数 2 的类型为“char *”[-Wformat=]
printf("Name buffer address: %x\n", buffer);
代码:
#include <string.h>
#include <stdio.h>
main(){
char name[200];
printf("What is your name?\n");
scanf("%s", name);
bo(name, "uname -a");
}
int bo(char *name, char *cmd){
char c[40];
char buffer[40];
printf("Name buffer address: %x\n", buffer);
printf("Command buffer address: %x\n", c);
strcpy(c, cmd);
strcpy(buffer, name);
printf("Goodbye, %s!\n", buffer);
printf("Executing command: %s\n", c);
fflush(stdout);
system(c);
}
【问题讨论】:
-
相关问题我发现对我的特殊情况很有帮助:stackoverflow.com/questions/19478509/…
标签: c printf format-specifiers