Declaring an array of records in MC++

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

Join Date: Jun 2005
Posts: 69
Reputation: DotNetUser is an unknown quantity at this point 
Solved Threads: 0
DotNetUser DotNetUser is offline Offline
Junior Poster in Training

Declaring an array of records in MC++

 
0
  #1
Mar 14th, 2006
How do you declare an array of records in MC++? And have a ptr point to it? Thanks.
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 394
Reputation: Clinton Portis is on a distinguished road 
Solved Threads: 40
Clinton Portis's Avatar
Clinton Portis Clinton Portis is offline Offline
Posting Whiz

Re: Declaring an array of records in MC++

 
0
  #2
Mar 14th, 2006
  1. struct Record
  2. {
  3. string title;
  4. int playtime;
  5. Record *next;
  6. };
  7.  
  8. Record **ListOfRecords = new Record*[42];
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 69
Reputation: DotNetUser is an unknown quantity at this point 
Solved Threads: 0
DotNetUser DotNetUser is offline Offline
Junior Poster in Training

Re: Declaring an array of records in MC++

 
0
  #3
Mar 24th, 2006
How about declaring an array of records without using pointers?

I get an error when I declare it this way:

Record ListOfRecords[];

I want to have an array of 100 records. Then have a pointer point to the array. This way I can pass the address to a function for processing.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,485
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1478
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Declaring an array of records in MC++

 
0
  #4
Mar 24th, 2006
If MC is a C or C++ compiler, you have to put a number inside those brackets to tell it how big that array is going to bel
Record ListOfRecords[100];

You don't need another pointer in order to pass it to another function.
// use only ONE of the following, not all three.  It shows three ways 
// to code the function.
void foo(Record ListOfRecords[100])
void foo(Record ListOfRecords[]) << this is also ok
void foo(Record* ListOfRecords) << so is this
{
   // blabla
}

int main()
{
   Record ListOfRecords[100];
   // pass the array to function foo()
   foo(ListOfRecords); <<< see here
}
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