代码:

 /*************************************************************************
> 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)的更多相关文章

  1. warning: assignment from incompatible pointer type [enabled by default]

    kernel 编译产生这个警告的原因是 不兼容指针类型的赋值 这个原因很有可能是因为返回值和正在接受这个指针类型名不相同. // vim arch/arm/mach-omap2/usb-host.c ...

  2. 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 ...

  3. foreach的参数不是数组:Warning: Invalid argument supplied for foreach

    Warning: Invalid argument supplied for foreach() 问题Warning: Invalid argument supplied for foreach() ...

  4. Warning: Invalid argument supplied for foreach()

    经常对提交过来的数据进行双重循环,但是为空时会报错:Warning: Invalid argument supplied for foreach() 如下解决即可:foreach($data[$i]  ...

  5. puts函数

    1.puts函数是gets函数的输出版本,它把指定的字符串写到标准输出并在末尾添加一个换行符 #include <stdio.h> #include <stdlib.h> in ...

  6. 解决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 ...

  7. 【Python学习】函数参数传递方法四种(位置,关键字,默认值,包裹位置,包裹关键字传递)

    1. 位置传递: #--coding:utf-8-- def send(name,address): return 'package is sent to %s, located in %s' %(n ...

  8. C#中调用C++的dll的参数为指针类型的导出函数(包括二级指针的情况)

    严格来说这篇文章算不上C++范围的,不过还是挂了点边,还是在自己的blog中记录一下吧. C++中使用指针是家常便饭了,也非常的好用,这也是我之所以喜欢C++的原因之一.但是在C#中就强调托管的概念了 ...

  9. C++------------typedef 函数指针类型定义

    摘要bycrazyhacking:        typedef 是定义了一种"函数指针"类型,可以再声明很多变量.函数指针的定义是定义了一个变量. int max(int x,i ...

随机推荐

  1. Service总结

    Service Service的应用场景,以及和Thread区别 开启Service的两种方式以及区别 Service基础 Service是什么? Service(服务)是一个可以在后台长时间运行而没 ...

  2. 使用Indy解决Could not load SSL Library错误

    测试平台:DelphiXE7 + Indy 10.6.0.5169 + Win7 64bit 步骤: 1. SSL下载版本:openssl-1.0.1j-i386-win32 可去http://yun ...

  3. 基于Hadoop3.1.2集群的Hive3.1.2安装(有不少坑)

    前置条件: 已经安装好了带有HDFS, MapReduce, Yarn 功能的 Hadoop集群 链接: ubuntu18.04.2 hadoop3.1.2+zookeeper3.5.5高可用完全分布 ...

  4. JAVA 怎么链接 SQL Server 数据库(半详细)

    哇今天闲着没事准备把前几天链接数据库碰到的问题写到博客,写到一半浏览器切出去了,这个浏览器也没保存,晚上又写了一遍,唉 蛋疼呀╮(╯▽╰)╭!! 说一说连接数据库遇到的问题,唉问题繁多,原来自己刷的精 ...

  5. mpvue + Vant weapp + 微信云服务 打造小程序应用

    写在前面的话: 从事小程序开发已经大半年的时间了,但是一直都是再用原生写项目.一直想着用框架自己写一个小程序,但苦于一直没有时间.正好最近项目搁置,有了空闲时间,就研究了下mpvue + Vant w ...

  6. mybaits-plus总结

    import java.math.BigDecimal; import java.util.Arrays; import java.util.Date; import java.util.List; ...

  7. WEB前段(HTML+JS),后端(MYSQL+PHP)开发基础

    一.HTML HTML:超文本标记语言,可以加载JS/CSS/图片/链接等非文字的内容 一切的网页开发技术都需要建立在HTML的基础之上 HTML的结构和语法 HTML元素 注释:  <!-- ...

  8. dede调出所有栏目以及栏目下的二级栏目

    1.调出所有栏目以及栏目下的二级栏目 {dede:channelartlist typeid='top'}<a href="{dede:field name='typeurl'/}&q ...

  9. 百度easydl之图像分类构建是否佩戴口罩模型

    2020-02-14 今天试了下百度esaydl的图像分类方面的功能,其优点是主需要上传自己的数据集,不需要关注模型训练,就可以得到相应的结果.最后得到的模型可以调用云api在本地进行运行. 网址:h ...

  10. 124-PHP类析构函数

    <?php class myclass{ //定义一个类 public function __destruct(){ //定义析构方法 echo '析构方法执行.<br />'; } ...