标题:请问:指针程序出现这情况是什么原因,如何较好避免
取消只看楼主
natto
Rank: 1
等 级:新手上路
帖 子:27
专家分:5
注 册:2016-4-10
结帖率:70%
 问题点数:0 回复次数:0 
请问:指针程序出现这情况是什么原因,如何较好避免
请教一下:以下程序编译后,虽无错误,但出现如下的警告,英文意思百度了下,大约能看得懂是什么意思,但是不能理解,因为按书上所说,这样使用指针是可以,但是为什么会出现这种警告呢,又该怎么编写是相对比较正确的程序呢,请不吝指教,谢谢!
程序代码:
#include<stdio.h>
int add(int,int);
main()
{
    int x,y,z,*p,*q;
    printf("请输入一个数");
    scanf("%d %d",&x,&y);
    p=&x;q=&y;
    z=add(p,q);
    printf("%d\n",z);
}
int add(int *a,int *b)
{
    int sum;
    sum=*a+*b;
    return sum;
}

--------------------配置: vc6.0 - CUI Release, 编译器类型: Microsoft C++ Compiler--------------------


[Warning]  C4047: 'function' : 'int ' differs in levels of indirection from 'int *'
[Warning]  C4024: 'add' : different types for formal and actual parameter 1
[Warning]  C4047: 'function' : 'int ' differs in levels of indirection from 'int *'
[Warning]  C4024: 'add' : different types for formal and actual parameter 2
[Warning] C4028: formal parameter 1 different from declaration
[Warning]  C4028: formal parameter 2 different from declaration

完成编译 I:\electronic_practice\c_program\Console_Application_vc6\Console_Application_vc6.c: 0 个错误, 6 个警告
生成 I:\electronic_practice\c_program\Console_Application_vc6\vc6.0\Console_Application_vc6.obj
搜索更多相关主题的帖子: 如何 
2016-04-10 19:01



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-463486-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.349584 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved