一个函数可以返回两个值? [英] Can a function return two values?

查看:106
本文介绍了一个函数可以返回两个值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/3829167/returning-multiple-values-from-a-function\">returning从功能多个值

我有必须返回两个值的函数

I have a function which has to return two values

                    return(&ptr->keys[pos].value)
                    return Duplicate;

下面&功放; ptr->键[POS] .value的会给地址和重复是一个枚举值设置为2 ...如何在这两个值返回到另一个函数,insert_front这是一个链表这和放大器; ptr->按键[POS]。价值被用作第一地址链表。
应该是什么调用函数我应该写?

Here &ptr->keys[pos].value will give the address and Duplicate is a enum value set to 2... How to return these two values to another function, insert_front which is a linked list this &ptr->keys[pos].value is used as the first address for linked list. What should be the prototype of the calling function I should write?

推荐答案

您不能返回两个值。但是,您可以返回一个值,它是一个包含两个值的结构。

You can't return two values. However, you can return a single value that is a struct that contains two values.

这篇关于一个函数可以返回两个值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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