array of pointers to arrays???? C/C++

Meaningful discussion outside of the potato gun realm. Projects, theories, current events. Non-productive discussion will be locked.
User avatar
ramses
Staff Sergeant 2
Staff Sergeant 2
United States of America
Posts: 1679
Joined: Thu May 29, 2008 6:50 pm

Thu Dec 23, 2010 10:20 pm

Okay. I have 9 character arrays (to reduce memory consumption), each [2][12][12]. I would like to have an array of pointers to those arrays, and use it to pass a specific one of those arrays to a function.

I have tried many things as far as syntax goes.

Code: Select all


void optimize(unsigned char parameter[2][12][12] );

//for the sake of this, lets assume that all these arrays are declared and initialized.

int main()
{
unsigned char *large_tables[9]={&spark_table, &fuel_start_table,  &fuel_duration_table, &water_start_table,
                                      &water_duration_table, &intake_phasing_table, &intake_duration_table,          
                                      &exhaust_phasing_table, &exhaust_duration_table};  

optimize(*large_tables[subsystem]);
}

void optimize(unsigned char parameter[2][12][12] )
{
     // do stuff
}
I'm getting the following errors:

Code: Select all

 warning: array subscript has type 'char'
error: call of overloaded 'optimize(unsigned char&)' is ambiguous
in other configuretions (guessing), I got:

Code: Select all

cannot convert char (*)[2][12][12] to 'char' in initialization
invalid conversion from 'char' to char (*)[2][12][12]'
Any ideas? I would really rather this not be a 4d array, although that may be an option. I'd also rather NOT rewrite the whole program to use pointers with explicit address arithmetic.

Thanks,
Chris
POLAND_SPUD wrote:even if there was no link I'd know it's a bot because of female name :D
User avatar
jrrdw
Moderator
Moderator
United States of America
Posts: 6572
Joined: Wed Nov 16, 2005 5:11 pm
Location: Maryland
Has thanked: 39 times
Been thanked: 22 times
Contact:

Donating Members

Thu Dec 23, 2010 11:23 pm

Post this to Theopia's computer section TurboSuper can help you with this one.
User avatar
ramses
Staff Sergeant 2
Staff Sergeant 2
United States of America
Posts: 1679
Joined: Thu May 29, 2008 6:50 pm

Fri Dec 24, 2010 10:02 am

Thanks. I know there are some resident programmers here. I didn't realize Theopia was actually active.
POLAND_SPUD wrote:even if there was no link I'd know it's a bot because of female name :D
Post Reply