Wednesday, April 27, 2011

Return arrays from Function (C++)

#include
#include
#include
#include

using namespace std;

//function to return an array

int *funToReturnArray()
{
   int *ret = new int[10];
 
  for (int i=0; i<10; i++){
   ret[i]=i;
}
 
return ret;

}


//function to return an array
int funToReturnArrayTest()
{
    int *ret = new int[10];

    for (int i=0; i<10; i++){
    ret[i]=i;
}

return *ret;

}

char * CopyToDestination(char Src[], char Desc[], size_t size)
{

   char *newDestination = new char[19];
   for (int i=0; i
    newDestination[i] = Src[i];

}

return newDestination;
}

void main()
{
//Returning the array from function.................
   int *arr=0;
  arr = funToReturnArray();

for(int i=0; i<10;i++)
   cout<

delete [] arr;

 char *source="Source";
 char *destination="";

//Source and Destination example...
char* retDestination= CopyToDestination(source, destination, 12 );

for(int i=0; i<12;i++)
   cout<

delete[] retDestination;
}

Health Benefits of Cashews

  Benefits of Cashews. Healthy food is an integral part of healthy body. Regular exercises such as Yoga and healthy diet is important to...