码迷,mamicode.com
首页 > 其他好文 > 详细

指针的简单应用2

时间:2017-02-10 23:05:32      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:应用   ret   ide   判断   简单   简单应用   turn   include   return   

#include<stdio.h>

int divide(int a,int b,int *result);
int main()
{
 int a=5,b=2;
 int c;
 if(divide(a,b,&c))
 {
     printf("%d",c);
 }
 return 0;
}

int divide(int a,int b,int *result)
{
    int ret;
    if(b==0)
        ret=0;
    else
    {
        *result=a/b;
        ret=1;
    }
    return ret;
}

 

 

结果可以用指针带回去,而判断的结果直接用return 返回。

指针的简单应用2

标签:应用   ret   ide   判断   简单   简单应用   turn   include   return   

原文地址:http://www.cnblogs.com/hanlu-blog/p/6388097.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!