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 ...
随机推荐
- 获取QQ状态接口开发示例
unit checkqqstatus; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Control ...
- python中numpy矩阵运算操作大全(非常全)!
python中numpy矩阵运算操作大全(非常全) //2019.07.10晚python矩阵运算大全1.矩阵的输出形式:对于任何一个矩阵,python输出的模板是:import numpy as n ...
- 《Java并发编程的艺术》并发编程的基础(四)
一.线程简介 1.线程的概念 系统运行的最小单元 2.为何使用多线程 更好地利用系统资源(处理器多核心),提高响应速度. 3.线程的状态 NEW(创建状态) RUNABLE(运行状态,系统调度,争抢时 ...
- maven在windows下的安装配置及手动引入oracle数据库jar包
一.maven的安装配置 注意:在进行如下配置之前,有个前提是你的java的jdk安装配置正确才行 1.首先,下载maven,网址http://maven.apache.org/download.cg ...
- 基于高德开放平台Map Lab的数据可视化
在Map Lab上创建可视化项目,首先需要添加数据.添加数据有4种方式,分别是: 上传CSV文件添加数据 上传Excel文件添加数据 连接在线数据库添加数据 提供在线数据API添加数据 一.数据上传说 ...
- doc转docx
# -*- coding: utf-8-*- import win32com from win32com.client import Dispatch w = win32com.client.Disp ...
- JavaScript.StringObjec.replace
//StringObject.replace(/regexp/,newContent); //1当newContent为新字符串,就直接用newContent对匹配的内容进行替换. //2当newCo ...
- Django——整体结构/MVT设计模式
MVT设计模式 Models 封装数据库,对数据进行增删改查; Views 进行业务逻辑的处理 Templates 进行前端展示 前端展示看到的是模板 --> 发起 ...
- 113-PHP使用instanceof判断变量是否为某个类对象
<?php class ren{ //定义人类 } class mao{ //定义猫类 } $ren=new ren(); //实例化一个人类的对象 $mao=new mao(); //实例化一 ...
- HDU_4960 2014多校9 Another OCD Patient DP
其实现在想起来是个巨简单的DP,模型就跟LCS很像,比赛的时候居然没想出来,在聪哥提醒下还卡了个地方 就是说给定一串n个数字的序列,可以连续合并,最终使得序列是回文的,题目也给定了合并数字所需的代价, ...