Hi


I have a structure of members uint x,uint y (name is "ruudud") declared as global variable.

Iv declared structure and pointer to structure globally in following way:

struct ruudud{
        unsigned int x: 6;  // 64 max
        unsigned int y: 6;
        };
        
struct  ruudud *r_ptr;

Iv allocated memory in following way: r_ptr = (struct ruudud*)calloc( lenght, sizeof(struct ruudud)); At this point i like to add progressively array elements to 2-nd dimention.

How i can do that? And how i can get components of array elements out of x-location from 2 dim arrays.

I can get information of x-location from 1 dim array by using: information = ((r_ptr + locationNumber) -> y);

Right away, I would use array notation.

information = r_ptr[locationNumber].y;

Your 2D array. Is that a pointer to pointer like

struct  ruudud **r_ptr;

or

struct  ruudud r_ptr[4][4];
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.