Dynamic Memory Allocation of Array of Structures.

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2008
Posts: 334
Reputation: Prabakar is on a distinguished road 
Solved Threads: 29
Prabakar's Avatar
Prabakar Prabakar is offline Offline
Posting Whiz

Re: Dynamic Memory Allocation of Array of Structures.

 
0
  #11
Jul 30th, 2008
records** myarray;
myarray = new records*[numRecords];
(*myarray[i]).title = "w/e";//same as...
myarray[i]->title = "w/e";
Storing values before allocating memory for 'em? I will be surprised if it works.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 401
Reputation: CoolGamer48 is on a distinguished road 
Solved Threads: 40
CoolGamer48's Avatar
CoolGamer48 CoolGamer48 is offline Offline
Posting Pro in Training

Re: Dynamic Memory Allocation of Array of Structures.

 
0
  #12
Jul 30th, 2008
Originally Posted by Prabakar View Post
Storing values before allocating memory for 'em? I will be surprised if it works.
Oh, right. Sorry.
  1. records** myarray;
  2. myarray = new records*[numRecords];
  3. for(int i = 0;i < numRecords;i++)
  4. myarray[i] = new records;
  5. (*myarray[2]).title = "w/e";//same as...
  6. myarray[2]->title = "w/e";
I'm a student. If my statements seem too absolute, feel free to coat them with "In my opinion..." or "I believe...".
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 32
Reputation: coveredinflies is an unknown quantity at this point 
Solved Threads: 0
coveredinflies coveredinflies is offline Offline
Light Poster

Re: Dynamic Memory Allocation of Array of Structures.

 
0
  #13
Jul 30th, 2008
Thanks had got a bit confused so didn't spot the obvious
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC