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 ...
随机推荐
- poj 2376 Cleaning Shifts 最小区间覆盖
Cleaning Shifts Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 40751 Accepted: 9871 ...
- B. Yet Another Crosses Problem
B. Yet Another Crosses Problem time limit per test 2 seconds memory limit per test 256 megabytes inp ...
- eclipse 安装spring tools suite插件
之前使用idea进行springboot项目的开发学习,但是由于idea是收费的,总是用着用着说验证码到期之类的,总之还是很不爽,于是就想重新采用eclipse开发springboot项目,为了方便s ...
- JPA#ManyToMany
多对多,多个学生选了多个课程. 涉及到的注解(注解的使用看注释):ManyToManyJoinTableJsonIgnoreProperties @Entity @Table(name = " ...
- 019-PHP创建目录函数
<?php if (mkdir("myDir1", 0777)) //创建目录的函数 { print("目录创建成功"); //目录建立成功 } else ...
- Eclipse 中打开工程目录的插件
我们想在Eclipse中的打开工程目录,Eclipse 自身没有这个功能,我们可以安装一个插件来实现这个功能.具体的操作方法如下: (1).到以下链接中下载插件:https://github.com/ ...
- 修改ssh主机名
三台机器的配置相似,以zk1为例 1.修改hostname vi /etc/hostname zk1 2.修改hosts文件 vi /etc/hosts 10.45.48.233 zk1 10.45. ...
- kafka cmd with ssl
set PATH=C:\Program Files\Java\jdk1.8.0_201\bin;@call kafka-consumer-groups.bat --bootstrap-server l ...
- ls 查看文件
1.按文件大小查看文件 a.降序:ls -lsh moudaen@morton:~$ ls -lshtotal 20M 20M -rw-r--r-- 1 moudaen 65536 20M Nov ...
- md5sum|zip|
##move## ;i<=;i++));do cp combine_all.split_$i split_$i;done ##gzip## mkdir gzip/workshell ;i< ...