-2

I want create a function and return two integers: i and c. How can i do this? Thanks in advance

a++ ;
 if(i == 288){
 a = 0 ;
 i-- ;
 b++ ;
 c++ ;
 } 
 if(c == 5000) {

 i = 0 ;
 c = 0 ;

 }
  if(a == 1 ){
   P2OUT = 0xFF ;
  a = 0 ;
  }
 if (b == 1){
 P2OUT= 0x00 ;
 b = 0 ; 

 }
Mustafa
  • 37
  • 1
  • 7
  • Pack those integers into a struct and return it from the function. Otherwise you could pass those int variables by reference to the function – sebastian Mar 25 '19 at 19:27
  • @ShadowRanger: Makes me wonder if that question should reopened. There are some good answers there. – Fred Larson Mar 25 '19 at 19:29
  • 1
    The code you've posted isn't a function... Nor is it clear what you'd want to return. – ShadowRanger Mar 25 '19 at 19:29
  • 2
    @FredLarson: Weather Vane's duplicate is still open, and more specific (I agree the one I found is a little broad, since it's unclear if they want to return a variable number of homogeneous things or a fixed number of potentially heterogeneous things). – ShadowRanger Mar 25 '19 at 19:31
  • Example: [`div()`](https://linux.die.net/man/3/div) returns 2 `int`s. – chux - Reinstate Monica Mar 26 '19 at 02:07

1 Answers1

2
struct s1
{
    int a;
    int b;
    /* more */
}

struct s1 foo(/* ... */)
{
    struct s1 s;

    s.a = /* something */;
    s.b = /* something */;
    /* more */
    return s;
}

int foo1(int *a, int *b /*, .... */ )
{
    *a = /* something */;
    *b = /* something */;
    return /* something */;
}
0___________
  • 60,014
  • 4
  • 34
  • 74