Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

The function must return one value only, how we can return more than one value in the functions?

user-image
Question added by Noha Moustafa Mahmmoud Moustafa , مندوبة مبيعات لاجهزة طبية و صيانتها , ايجيكير للاجهزة الطبية
Date Posted: 2017/04/15
Nabil Rageh
by Nabil Rageh , Technical Support Manager , DenTech for communication and Information Technology

you can return a struct from a function like the next example:

 

struct TwoVars

{

 byte Var1;

 byte Var2;

};

 

void setup ()

{

}

 

void loop ()

{

 struct TwoVars Vars = ReturnToVars(5, 10);

 byte SeparateByte1 = Vars.Var1;

 byte SeparateByte2 = Vars.Var2;

}

 

struct TwoVars ReturnToVars (byte FirstVar, byte SecondVar)

{

 struct TwoVars MyTwoVars;

 

 MyTwoVars.Var1 = FirstVar;

 MyTwoVars.Var2 = SecondVar;

 

 return MyTwoVars;

}

Ahmed Gamal Soliman
by Ahmed Gamal Soliman , Senior Oracle Adf Developer , Personal Project

 We can return more than one value by array value because array is complex varible

We can make functions return by array value

Return type [ ] function name ( arguments)

More Questions Like This