本帖最后由 bin554385863 于 2019-11-7 19:12 编辑
返回结构体或者数组#include <stdio.h>
typedef struct
{
int MIN;
int MAX;
} limitValue;
limitValue func(int m, int n)
{
limitValue result = {m < n ? m : n, m > n ? m : n};
return result;
}
int main()
{
int a = 100, b = 900;
printf("min = %d, max = %d", func(a, b).MIN, func(a, b).MAX);
return 0;
}
------------------------------------------------------------------------------------
Microsoft Windows [版本 10.0.18363.418]
(c) 2019 Microsoft Corporation。保留所有权利。
E:\Users\admin\Documents\VScode>c:\Users\admin\.vscode\extensions\ms-vscode.cpptools-0.26.1\debugAdapters\bin\WindowsDebugLauncher.exe --stdin=Microsoft-MIEngine-In-mzpoo3em.x14 --stdout=Microsoft-MIEngine-Out-rvx2lzal.n2o --stderr=Microsoft-MIEngine-Error-k0rjejv2.e35 --pid=Microsoft-MIEngine-Pid-jdwlq5oa.nev --dbgExe=D:\MinGW\bin\gdb.exe --interpreter=mi
min = 100, max = 900
E:\Users\admin\Documents\VScode> |