Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

is this bad?

Name: Anonymous 2013-08-27 12:46


struct something floattosomething(float f){
       struct something * ret = (struct something*)malloc(sizeof(struct something));
       ret->type = 3;
       ret->f = f;
       return *ret;
}

Name: Anonymous 2013-08-27 13:42

>>3
return type of *ret is value of pointer at ret. It crashes because it tries to copy the value of entire struct to the stack. instead of the pointer
you should try
 return ret;

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List