Returnig multiple arrays from function

Hello

i want assign ip address, netmask address and gateway address to the arduino from user.

  1. Question :
    Can i use reading input like they are getting values from array where user typed the desired values ?
IPAddress ip(IPaddress[4]);
IPAddress subnet(MASKaddress[4]);
IPAddress gateway(GATEaddress[4]);

or like

IPAddress ip(IPaddress[0],IPaddress[1],IPaddress[2],IPaddress[3]);
IPAddress subnet(MASKaddress[0],MASKaddress[1],MASKaddress[2],MASKaddress[3]);
IPAddress gateway(GATEaddress[0],GATEaddress[1],GATEaddress[2],GATEaddress[3]);
  1. Question :
    If i dynamically allocate array in function, how can i assign it to return different arrays to specific inputs ?
    Or how to set up that i am setting up array named IPaddress ? Or can i point to globally created array and len the function do its work and then function will return specific array to global array ? how to use that one function to return all three arrays separated ?

how i mean it :

void loop(){

GetAddress(IPaddress[4]);
GetAddress(MASKaddress[4]);
GetAddress(GATEaddress[4]);

Serial.println(ip);
Serial.println(subnet);
Serial.println(gateway);

}

int* GetAddress() {

int *address = (int*)malloc(sizeof(int)*4) 

*address = //input of the user, three numbers before "." will be saved here 
*(address+1) = //input of the user, three numbers after first "." will be saved here 
*(address+2) = //input of the user, three numbers after second "." will be saved here 
*(address+3) = //input of the user, three numbers after third "." will be saved here 

/* Please, will you will help me with conditions that are in comments too ?
    Or just tell me some tips how to write it ? thanks */

//user defined array 
//for example : IPaddress[4] = (*address,*(address+1),*(address+2),*(address+3));
//and when it is saved in global array it will delete allocated storage ...
delete GetAddress;
}

can someone help me please ? ask questions if you dont understand and i will try to explain it more better. thanks

when you write thisGetAddress(IPaddress[4]); you are calling the function GetAddress with the 5th element of the IPaddress array as a parameter.... is that your intent?

a pointer to an array is just the name of the array.

No ot is not ... i taught that it will call for full array and in brackets is size of the array (in array are four elements)
So this is wrong definition of call in that array ?
I meant it like result from GetAddress will be assigned to (IPaddress) which is array of size 4

I want it to put the values in that array and values from array input in ip address ...

what do you call "an input"?

You can initialize the array's element at definition time, when you do int myArray[] = {1,2,3,4};for example but if you did not initialize of want to set the values later on, you can't do that

 int myArray[4];
...
myArray[0] = 1;
myArray[1] = 2;
myArray[2] = 3;
myArray[3] = 4;

also what do you call "dynamically allocating"? --> sing malloc()?

If you're using globals, there's no need to return anything.

I would convert into HEX and store all three addresses into one String array entry.

Are you planning to store the data?

I would convert into HEX and store all three addresses into one String array entry.

Why String ?
Why Hex ?

Say the IP address is 192.10.1.100.

As HEX I would just need to store string “C0100164”

Adding Subnet and Gateway addresses to the same string would make it simple to just have one variable that contains the complete address.

Slumpert:
I would convert into HEX and store all three addresses into one String array entry.

I'd avoid Strings. Why spend 14 bytes when 4 will suffice?
YMMV

Say the IP address is 192.10.1.100.

As HEX I would just need to store string "C0100164"

Store the IP address in an array of bytes. It only takes 4 bytes and there is no overhead caused by using the String library.