Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

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

user-image
Question ajoutée par Noha Moustafa Mahmmoud Moustafa , مندوبة مبيعات لاجهزة طبية و صيانتها , ايجيكير للاجهزة الطبية
Date de publication: 2017/04/15
Nabil Rageh
par 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
par 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