开发者社区> 问答> 正文

warning: format %s expects type char * but argument 2 has type int

尝试用crypt的时候遇到了这个问题
源代码如下:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char **argv)
{
printf("%s\n", crypt(argv[1], argv[2]));
return 0;
}

用命令gcc -o test lizi.c -lcrypt编译连接时有如下警告:
lizi.c:7:2: 警告: 格式 ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat]

没理由啊,crypt的返回值不可能是整数啊,而且如果运行则会提示段错误

展开
收起
a123456678 2016-06-17 16:38:15 5442 0
1 条回答
写回答
取消 提交回答
  • #include <crypt.h>
     /*或者*/
    #define _GNU_SOURCE
    #include <unistd.h>
    Please see: man feature_test_macros
    2019-07-17 19:43:05
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
How big data can help small data? 立即下载
Why you should care about data layout in the file system 立即下载
The Value of Exploratory Data 立即下载