|
-
January 5th, 2012, 12:14 PM
#1
how to refer to 2 dimensional array address
i have a problem here. I want to retrieve a data using memcpy.
code
////////////////////////////////////////////////////////////////////////////
unsigned char m_Data[256];
//m_Data = "Hello word";
unsigned char Dest[256];
int Data_Length = 11;
memcpy(Dest, m_Data +2, Data_Length);
///////////////////////////////////////////////////////////////////////////////
I have no problem with the above coding;
The problem is when my m_Data is 2 dimensional array, How do i do it?
code:
//////////////////////////////////////////////////////////////////////////////////
unsigned char m_Data[5][256];
//m_Data[0][256] = "Hello word";
//m_Data[1][256] = "Hell02";
//m_Data[2][256] = "Hello3";
unsigned char Dest[256];
int Data_Length = 11;
//the nRow will be known variable, which we iterate through
for(int nRow=0; nRow<5;nRow++)
memcpy(Dest, m_Data + (nRow*256) +2, Data_Length); //is this correct but i got crash here
//process here
////////////////////////////////////////////////////////////////////////////////////////////
Can someone help over here?
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|