Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save msr1k/9b4e528d2726ab54cbf7 to your computer and use it in GitHub Desktop.
Save msr1k/9b4e528d2726ab54cbf7 to your computer and use it in GitHub Desktop.
#include <stdio.h>
char gData[2][2][2] = {
{
{ 1, 2 },
{ 3, 4 },
},
{
{ 5, 6 },
{ 7, 8 },
},
};
int get_result( char (**data)[2][2][2] )
{
printf( "gData: %08X\n", &gData );
*data = &gData;
return 0;
}
typedef struct {
char result[2][2][2];
} ResultData;
ResultData gResultData = {
{
{
{ 1, 2 },
{ 3, 4 },
},
{
{ 5, 6 },
{ 7, 8 },
},
}
};
int get_result_data( ResultData ** data )
{
printf( "gData: %08X\n", &gData );
*data = &gResultData;
return 0;
}
int main(int argc, char const* argv[])
{
int i, j, k;
char (*data)[2][2][2];
ResultData* resultData;
get_result( &data );
printf( "data: %08X\n", data );
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {
for (k = 0; k < 2; k++) {
printf( "%02X\n", (*data)[i][j][k] );
}
}
}
get_result_data( &resultData );
printf( "data: %08X\n", resultData );
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {
for (k = 0; k < 2; k++) {
printf( "%02X\n", resultData->result[i][j][k] );
}
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment