Login    Register
User Information
Username:
Password:
We are a free and open
community, all are welcome.
Click here to Register
Sponsored
Who is online

In total there are 59 users online :: 3 registered, 0 hidden and 56 guests


Most users ever online was 155 on Mon Aug 15, 2016 1:40 am

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot] based on users active over the past 5 minutes

The Team
Administrators
Global Moderators
global_moderators.png CS

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

All non-spudgun related discussion goes here such as projects, theories, serious questions, etc. All "off-topic" posts (aka useless posting, determined by moderators) will be removed.
Sponsored 
  • Author
    Message

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

Unread postAuthor: ramses » 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
  • 0

POLAND_SPUD wrote:even if there was no link I'd know it's a bot because of female name :D
User avatar
ramses
Major General
Major General
 
Posts: 1679
Joined: Thu May 29, 2008 6:50 pm
Reputation: 3

Unread postAuthor: jrrdw » Thu Dec 23, 2010 11:23 pm

Post this to Theopia's computer section TurboSuper can help you with this one.
  • 0

When life gives you lemons...throw them back they suck!
User avatar
jrrdw
Donating Moderator
Donating Moderator
 
Posts: 6538
Joined: Wed Nov 16, 2005 5:11 pm
Location: Maryland
Country: United States (us)
Reputation: 25

Unread postAuthor: ramses » Fri Dec 24, 2010 10:02 am

Thanks. I know there are some resident programmers here. I didn't realize Theopia was actually active.
  • 0

POLAND_SPUD wrote:even if there was no link I'd know it's a bot because of female name :D
User avatar
ramses
Major General
Major General
 
Posts: 1679
Joined: Thu May 29, 2008 6:50 pm
Reputation: 3

Return to Non-Spudgun Related Discussion

Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]

Reputation System ©'