0

I need to make one 2D array in which one column store the pointer of some structure & another column store one 32 bit magic number. how can i do it in 2D array.? or any other method to keep track of this two columns info?

0

2 Answers 2

3

You can use:

// The struct that will hold the pointer and the magic number
struct data {
    void *other_struct_ptr;
    unsigned int magic_number;
};

// Declare my array
struct data array[N];

Where N is the size of your array. Now just fill your data into the array. For example:

array[0].other_struct_ptr = NULL; // I used NULL for simplicity
array[0].magic_number = 0xDEADC0DE;
array[1].other_struct_ptr = NULL;
array[1].magic_number = 0xCAFEBABE;
Sign up to request clarification or add additional context in comments.

Comments

1

Define a struct like this:

struct data_t
{
    void *pointer;
    int magic_number;
};

Then use following array:

data_t values[100]; //100 is just for example

Or maybe you need such 2D array:

data_t values[100][100]; //100s are just for example

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.