How do you declare an array of records in MC++? And have a ptr point to it? Thanks.

struct Record
{
   string title;
   int playtime;
   Record *next;
};

Record **ListOfRecords = new Record*[42];

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.

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
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.