バージョン 1:
struct mydef_s1 {
int argc;
char *argv[3];
};
struct mydef_s1 *p1 = (struct mydef_s1*) malloc (sizeof (struct mydef_s1));
p1->argv[0] = malloc (8);
p1->argv[1] = malloc (16);
p1->argv[2] = malloc (24);
Now, I want to achieve above with the following structure declaration?
バージョン 2:
struct mydef_s2 {
int argc;
char **argv;
};
私が正しければ、以下は8バイトだけを割り当てたいと思います(私のマシンのメモリポインタ用に4つと整数用に4つ)
struct mydef_s2 *p2 = (struct mydef_s2*) malloc (sizeof (struct mydef_s2));
次のことを行うにはどうすればよいですか?
p2->argv[0]= malloc(4);
p2->argv[1]=malloc(8);