puts函数出现warning: passing argument 1 of ‘puts’ from incompatible pointer type(警告:从不兼容的指针类型传递“puts”的参数1)
代码:
/*************************************************************************
> File Name: ptr_variable.c
> Author: Mr.Yang
> Purpose:演示指向变量的指针
> Created Time: 2017年06月03日 星期六 08时47分33秒
************************************************************************/ #include <stdio.h>
#include <stdlib.h> int main(void)
{
int a = ;
printf("a的地址为:%d\n",&a); int *p;
puts(p);
printf("指针p的地址为:%d\n",&p); return ;
}
错误完整描述:
ptr_variable.c: In function ‘main’:
ptr_variable.c::: warning: passing argument of ‘puts’ from incompatible pointer type
puts(p);
^
In file included from ptr_variable.c:::
/usr/include/stdio.h::: note: expected ‘const char *’ but argument is of type ‘int *’
extern int puts (const char *__s);
^
由描述可知,puts需要const char *但是参数给了 int *,通过查询puts函数的用法(如下:附)可知,里面是一个字符串参数,不是int型参数,所以上面的代码可把int *p改为char *p即可编译通过。
附:puts()函数用于将一字符串放到标准输出流(stdout)中,并在最后增加换行符 '\n',其函数原型如下:
int puts(char *string);
puts函数出现warning: passing argument 1 of ‘puts’ from incompatible pointer type(警告:从不兼容的指针类型传递“puts”的参数1)的更多相关文章
- warning: assignment from incompatible pointer type [enabled by default]
kernel 编译产生这个警告的原因是 不兼容指针类型的赋值 这个原因很有可能是因为返回值和正在接受这个指针类型名不相同. // vim arch/arm/mach-omap2/usb-host.c ...
- passing argument 3 of ‘wtk_hlv_rec_init’ discards ‘const’ qualifier from pointer target type
-Werror,编译出现如下错误: src/wtk/exam/wtk_ndx.c:154:6: error: passing argument 3 of ‘wtk_hlv_rec_init’ disc ...
- foreach的参数不是数组:Warning: Invalid argument supplied for foreach
Warning: Invalid argument supplied for foreach() 问题Warning: Invalid argument supplied for foreach() ...
- Warning: Invalid argument supplied for foreach()
经常对提交过来的数据进行双重循环,但是为空时会报错:Warning: Invalid argument supplied for foreach() 如下解决即可:foreach($data[$i] ...
- puts函数
1.puts函数是gets函数的输出版本,它把指定的字符串写到标准输出并在末尾添加一个换行符 #include <stdio.h> #include <stdlib.h> in ...
- 解决warning: #181-D: argument is incompatible with corresponding format string conversion警告
uint8_t NetRSSI=0;uint8_t NetBer=0;uint8_t failtime=0; sscanf(&USART_RX_BUF[0],"%*s%u,%u&qu ...
- 【Python学习】函数参数传递方法四种(位置,关键字,默认值,包裹位置,包裹关键字传递)
1. 位置传递: #--coding:utf-8-- def send(name,address): return 'package is sent to %s, located in %s' %(n ...
- C#中调用C++的dll的参数为指针类型的导出函数(包括二级指针的情况)
严格来说这篇文章算不上C++范围的,不过还是挂了点边,还是在自己的blog中记录一下吧. C++中使用指针是家常便饭了,也非常的好用,这也是我之所以喜欢C++的原因之一.但是在C#中就强调托管的概念了 ...
- C++------------typedef 函数指针类型定义
摘要bycrazyhacking: typedef 是定义了一种"函数指针"类型,可以再声明很多变量.函数指针的定义是定义了一个变量. int max(int x,i ...
随机推荐
- TS文件极简合并
TS文件是可以直接通过二进制拷贝连接的方式进行合并的,一般采用如下的命令行参数:copy /b 1.ts+2.ts+3.ts new.ts 这个例子就是将1.ts.2.ts.3.ts三个文件按顺序连接 ...
- go_http
httpSvr // HandleFunc registers the handler function for the given pattern // in the DefaultServeMux ...
- scala文件通过本地命令运行
1.准备(检查) a.本地环境安装jdk b.安装scala 2.sublime编辑scala文件,并存放到F:\plan_next\scala_compile下 3.文件目录中切换到cmd中(文件目 ...
- OSDA - 一个以MIT协议开源的串口调试助手
市场其实有很多开源的串行端口调试助手(Open Serial Port debug assistant),但其中很大一部分没有明确的开源协议,还有一部分只限个人使用,所以编写了一个并以MIT协议授权开 ...
- Pycharm使用python3无法通过HTMLTestRunner生成测试报告《转载》
Pycharm使用python3无法通过HTMLTestRunner生成测试报告: https://blog.csdn.net/weixin_38981172/article/details/8238 ...
- flink任务性能优化
如何提高 Flink 任务性能 一.Operator Chain 为了更高效地分布式执行,Flink 会尽可能地将 operator 的 subtask 链接(chain)在一起形成 task,每个 ...
- SQL优化工具 - SQL Server Profiler与数据库引擎优化顾问
最近项目做到几千个学生分别去人脸识别记录(目前约630000行)中查询最后一次记录,可想而知性能这块是个麻烦.于是乎,GET到了SQL Server Profiler和数据库引擎优化顾问这俩工SHEN ...
- hive表字段注释显示乱码问题
创建了一张hive表,对字段增加了注释,比如comment '注释内容' 之类的,但是在hive client查看时候却是乱码 比如: create table test_ultraedit ( id ...
- junit基础学习之-引用spring容器的测试(7)
context 自动注入的文章链接:http://www.360doc.com/content/11/0815/09/2371584_140471325.shtml
- webpack散记--Typescript
Typescript 1.js的超集 官网:typescriptlang.org/tslang.cn 来自:微软 安装:官方的 npm i typescript ts-loader --save-d ...