代码:

 /*************************************************************************
> 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. 将.py文件转化成.exe

    机子上已经安装好python,且配置好环境变量 编写好xx.py文件 安装pywin32.此处一定注意pywin32有32位和64位之分.可以在命令提示符里输入python来查看python的版本以及 ...

  2. [YOLO]《YOLO9000:Better, Faster, Stronger》笔记

    一.简单介绍 YOLO9000(也叫YOLO v2),主要是在YOLO v1的基础上做了改进,而且效果还是比较显著的,在原论文中,作者提到的改进大致包括两个工作: 1.检测性能上的改进,提出了YOLO ...

  3. JAVA-数据类型-复习

    JAVA-数据类型-复习 Java中,一共有8种数据类型,4种整型,2种浮点型,1种用于表示Unicode编码的字符单元的字符类型char,1种布尔类型. 整型 类型 存储需求(字节)一个字节包含8个 ...

  4. Django 初体验

    Django 依赖的python 基础环境安装: https://www.runoob.com/django/django-install.html Django安装参考官网文档: https://d ...

  5. Docker 和虚拟机的区别

    版权所有,未经许可,禁止转载 章节 Docker 介绍 Docker 和虚拟机的区别 Docker 安装 Docker Hub Docker 镜像(image) Docker 容器(container ...

  6. 批量go get 代码

    批量 go get 代码 Go

  7. [BJDCTF2020]The mystery of ip

    0x00 知识点 SSTI模板注入: 之前也写过: https://www.cnblogs.com/wangtanzhi/p/12238779.html SSTI模板注入: 模板注入涉及的是服务端We ...

  8. WIN10怎么查看端口,并杀死进程

    在命令行执行一下命令 netstat -ano | findstr "

  9. POJ1338 & POJ2545 & POJ2591 & POJ2247

    POJ1338 2545 2591 2247都是一个类型的题目,所以放到一起来总结 POJ1338:Ugly Numbers Time Limit: 1000MS   Memory Limit: 10 ...

  10. windows driver 枚举串口

    //枚举串口 NTSTATUS status; HANDLE hKey = NULL; OBJECT_ATTRIBUTES oa; UNICODE_STRING strPath = RTL_CONST ...