解析如何用指针实现整型数据的加法
本篇文章是对用指针实现整型数据加法的方法进行了详细的分析介绍,需要的朋友参考下
代码如下所示:
#include <stdio.h>
int *add(int a,int b)
{
int c = 0; //原题没有这行
int *p = NULL;
p = &c; //原题没有这行
*p = a+b;
return p;
}
int main(void)
{
printf("%d/n",*add(2,3));
return 0;
}
代码如下:
#include <stdio.h>
int *add(int a,int b)
{
int c = 0; //原题没有这行
int *p = NULL;
p = &c; //原题没有这行
*p = a+b;
return p;
}
int main(void)
{
printf("%d/n",*add(2,3));
return 0;
}
- 上一篇:基于typedef的用法详解
- 下一篇:解决不用sizeof求出int大小的方法
精彩图集
精彩文章