943,547 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 4799
  • C++ RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Jul 30th, 2008
0

Re: Dynamic Memory Allocation of Array of Structures.

Quote ...
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.
Reputation Points: 94
Solved Threads: 33
Posting Whiz
Prabakar is offline Offline
342 posts
since May 2008
Jul 30th, 2008
0

Re: Dynamic Memory Allocation of Array of Structures.

Click to Expand / Collapse  Quote originally posted by Prabakar ...
Storing values before allocating memory for 'em? I will be surprised if it works.
Oh, right. Sorry.
C++ Syntax (Toggle Plain Text)
  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";
Reputation Points: 77
Solved Threads: 40
Posting Pro in Training
CoolGamer48 is offline Offline
401 posts
since Jan 2008
Jul 30th, 2008
0

Re: Dynamic Memory Allocation of Array of Structures.

Thanks had got a bit confused so didn't spot the obvious
Reputation Points: 10
Solved Threads: 0
Light Poster
coveredinflies is offline Offline
32 posts
since Jul 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: simple thread question
Next Thread in C++ Forum Timeline: calling multiple DLLs in CLR





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC