C language function multiple return values

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 returnreturn 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;
	}

Guess you like

Origin blog.csdn.net/m0_43456002/article/details/105667105