Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
Having issues with multi-dimensional array (Read 363 times)
orbitcoms
Full Member
***
Offline



Posts: 45
Re: Having issues with multi-dimensional array
Reply #2 - Jul 31st, 2017 at 10:36pm
 
I did find that post initially and change the array structure declaration but still had issues. So, I reverted to setting up 3 arrays and getting values from each one.
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 8095
United Kingdom
Re: Having issues with multi-dimensional array
Reply #1 - Jul 31st, 2017 at 2:11pm
 
Back to top
 
WWW  
IP Logged
 
orbitcoms
Full Member
***
Offline



Posts: 45
Having issues with multi-dimensional array
Jul 31st, 2017 at 9:42am
 
This is more a c++ question (or maybe an Arduino print question)?

I have initialized a 2 dimensional array and attempt to access the array produced unexpected results. For the array below, I expect to get the 3 values assigned to row 0 but I get these 3 values instead?  1 , 4  and 7. Is this a problem with the way print is working or some issue with the way I am accessing the array? It looks ok to me but I cannot see what is happening. Its probably something very simple/silly I have overlooked.

Note: If I set up a 1-dimensional array and test it, I get correct elements returned.

byte freq[10][3] =
{
{0x69,0x00,0x11},  //420
{0x69,0xc0,0x11},  //423
{0x6a,0x80,0x11},  //426
{0x6b,0x40,0x11},  //429
{0x6c,0x00,0x12},  //432
{0x6c,0xc0,0x12},  //435
{0x6d,0x80,0x12},  //438
{0x6e,0x40,0x12},  //441
{0x6f,0x00,0x12},  //444
{0x6f,0xc0,0x12}  //447
};

Serial.print(byte(freq[0,0])); Serial.print(byte(freq[0,1])); Serial.print(byte(freq[0,2]));

Thanks

Back to top
« Last Edit: Jul 31st, 2017 at 9:56am by orbitcoms »  
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print