Function returns multiple values
In normal projects, we will encounter a function to return multiple values. But the C language stipulates that a function can only return one value, which means that we can't return
return multiple values with one variable. What should I do?
In fact, it is very simple, and the structure can easily achieve this function. Attach a small demo below:
#include<stdio.h>
typedef struct more{
//结构体
int one;
int two;
}more;
more re()
{
more m = {
1,2};
return m;
}
int main()
{
more m = re();
printf("%d %d",m.one,m.two);
return 0;
}