如何在Xcode的一个输出中组合函数 [英] how to combine the function in the one output in Xcode

查看:26
本文介绍了如何在Xcode的一个输出中组合函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <stdio.h>
#define SPACE ' '
void branching_if_judgement(int a, int b){
    if (a > b){
        printf("a(%d) is larger than b(%d)\n", a, b);
    }else {[![enter image description here][1]][1]
        printf("a(%d) is smaller or equal to b(%d)\n", a, b);
    }
}

char branching_if_judgement_char(int a, int b){
    char res;
    if (a > b){
        printf("a(%d) is larger than b(%d)\n", a, b);
        res = 'Y';
    }else {
        printf("a(%d) is smaller or equal to b(%d)\n", a, b);
        res = 'N';
    }
    return res;
}
int main() {
    branching_if_judgement_char(2,3);
}

我按照示例运行代码.而且,幻灯片中缺少主要功能.我加了

I follow the example to run the code. And, there are missing the main function in the slide. I add it

所以,我的问题是如何在一个输出中组合所有功能,就像幻灯片一样.

So, my question is how to combine all function in the one output, just like the slide.

:

推荐答案

函数签名告诉我们

char branching_if_judgement_char(int a, int b)

它返回一个 char 类型的东西,它需要两个 int 类型的东西.

it returns a thing of type char, and it takes two things of type int.

因此,当您调用它时,您将两个东西传递给,而不是获取它返回的东西.

So when you call it, you're passing the two things to it, but not taking the thing it's returning.

branching_if_judgement_char(2,3);

正确的代码应该是

char p = branching_if_judgement_char(2,3);
printf("%c\n", p);

请抽时间阅读

这篇关于如何在Xcode的一个输出中组合函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆