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

Interesting C and C++

Name: Anonymous 2011-09-24 21:42

#include <stdio.h>
void* unodamrite();

struct Node { int d; Node *n; };
void main(){
Node* b = (Node *)unodamrite();
printf("%d", b->d);
}

void* unodamrite(){
Node n;
n.d = 10;
n.n = 0;
return &n;
}

Name: Anonymous 2011-09-24 21:53

The is absolutely nothing wrong with returning the address of a Malloc() object.  I'm surprised how many programmers don't understand this.  I just saw one on osdev!

I've written a compiler, so I know everything there is to know.

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