struct to bidimensional struct pointer assigment in C

Posted by argos.void on Stack Overflow See other posts from Stack Overflow or by argos.void
Published on 2010-12-24T01:04:00Z Indexed on 2010/12/24 1:54 UTC
Read the original article Hit count: 588

Filed under:
|
|

i want to get work this code and i googled and asked in efnet and freenode but i didnt find the answer. what i want i to assign a struct woot to an another bidimensional struct woot *, and i need malloc to do that. then, how can i use malloc there and how to assign the struct? thanks.

#include <stdio.h>
struct omg {
    int foo;
};
struct woot {
    struct omg *localfoo;
    int foo;
};
int a = sizeof(struct woot);
int main(void){
    struct woot *what[10][10] = (struct woot *) malloc(100*a);
    struct omg hahaha[100];
    hahaha[1].foo = 15;
    what[1][6].localfoo = &hahaha[1];
}

© Stack Overflow or respective owner

Related posts about c

    Related posts about pointers