Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how could i reallocate an array?

Status
Not open for further replies.

jayjay60

Programmer
Jun 19, 2001
97
FR
In my application, i consider 2 pointer on 2 array.
double *Qi1=new double[ni1];
double *Qi=new double[ni];

"i" and "i1"(=i-1) are 2 dates.
So, as we could see date i-1 is before date i. In my application i need to know all the value in the array which is pointed by Qi1, to calculate new values in the second array pointed by Qi(we note that ni>=ni1).
But, my pb is that as my application is iterative i do a for loop on the "i", so that at the end of all my calculation, just before going to the next step of the loop, i want that Qi "becomes" Qi1, like that i could continue the iteration, so i think that i have to do a reallocation of my tabs, and i don't know how we could do that. So could you give me a solution?

thanks in advance

jayjay
 


do{
Qi = ... whatever calculation;
double *temp = Qi;
Qi = Qi1;
Qi1 = temp;
}while(condition);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top