C++, return array from function : <p>Im building this subnet calculator but now im stuck, with array. I want to create new int function that will return array, but I don't know how I tried many things but still don't have idea, think it will have to do something with pointers. I want to create new function starting at "while(octet4>0)". so octet4 gets passed into function and function should return fully functional array which I can use then in main. Hope somebody will know answer for what im looking for, hope solution would not be too complicated because Im just learning programming and thought this would be fun project to take on.</p>

<pre><code>int main() {
int i=0,j,q,s,size=8,temp;
int binary_ip[8];
int netmask;
int mask;
int octet1, octet2, octet3, octet4; 
string ip;
cout&lt;&lt;"Vnesite IP naslov, npr. 192.168.32.55:"&lt;&lt;endl;
cin&gt;&gt;ip;
cout&lt;&lt;"Vnesite netmasko, npr. /27:"&lt;&lt;endl;
cin&gt;&gt;netmask;   

stringstream stream(ip);
char ch; 
stream &gt;&gt; octet1 &gt;&gt; ch &gt;&gt; octet2 &gt;&gt; ch &gt;&gt; octet3 &gt;&gt; ch &gt;&gt; octet4;


while(octet4&gt;0){
    binary_ip[i]=octet4%2;
    i++;
    octet4=octet4/2;
}

switch(i){
    case 7:binary_ip[7]=0;
    break;
    case 6:for(s=6;s&lt;=7;s++)binary_ip[s]=0; 
    break;
    case 5:for(s=5;s&lt;=7;s++)binary_ip[s]=0;
    break;
    case 4:for(s=4;s&lt;=7;s++)binary_ip[s]=0;
    break;
    case 3:for(s=3;s&lt;=7;s++)binary_ip[s]=0;
    break;
    case 2:for(s=2;s&lt;=7;s++)binary_ip[s]=0;
    break;
    case 1:for(s=1;s&lt;=7;s++)binary_ip[s]=0;
    break;
}

for(q=0;q&lt;size/2;q++){
    temp=binary_ip[size-1-q];
    binary_ip[size-1-q]=binary_ip[q];
    binary_ip[q]=temp;}

return 0;
}
</code></pre>
