Home > other >  Ask for the c programming problem
Ask for the c programming problem

Time:12-23

 typedef struct {

int a;

Void * b;

} test_t;





Void func3 - a non-class function (void * args)

{

Test_t tt=args (test_t *);



Printf (" % d: % s \ n ", tt - & gt; A, (char *) tt - & gt; B);

}







Int func2 (void * args, size_t len)

{

Void * s;



If (len) {

S=calloc (1, len);

Memcpy (s, args, len);

}

Func3 - a non-class function (s);



return 0;

}



Int func1 ()

{

Test_t t;

Const char * ss="abcddddd";



T.a=1;

T.b=strdup (ss);

Func1 ((void *) & amp; Siztof t, t);



return 0;

}





Int main ()

{

Func1 ();

exit(0);

}





Here would like to ask the following, func3 - a non-class function function of tt - & gt; B do you have any question, or point to the application in func1 memory?

Which bosses can analyze, a little dizzy,

CodePudding user response:

Func1 ((void *) & amp; Siztof t, t); Mistake, should be you want func2 ((void *) & amp; Siztof t, t);
Test_t tt=args (test_t *); Mistake, should be you want test_t * tt=(test_t * args);

S=in func2 calloc (1, len); Should already be a new memory
  • Related