Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Having issues with multi-dimensional array (Read 3668 times)
orbitcoms
Junior Member
**
Offline


Posts: 45
Joined: Jun 21st, 2017
Having issues with multi-dimensional array
Jul 31st, 2017 at 8:42am
Print Post  
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

« Last Edit: Jul 31st, 2017 at 8:56am by orbitcoms »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Having issues with multi-dimensional array
Reply #1 - Jul 31st, 2017 at 1:11pm
Print Post  
  
Back to top
WWW  
IP Logged
 
orbitcoms
Junior Member
**
Offline


Posts: 45
Joined: Jun 21st, 2017
Re: Having issues with multi-dimensional array
Reply #2 - Jul 31st, 2017 at 9:36pm
Print Post  
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
 
Page Index Toggle Pages: 1
Send TopicPrint