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

Pages: 1-

C structs

Name: Anonymous 2013-07-15 8:43

/Prog/, just a minute of your time, please. I'm reading a book and it has a piece of C code like this:

typedef struct {
 void (*print) (struct * shape);
 // data fields
} shape;

I'm trying to compile it and it doesn't work, I'm guessing it's because the book is old. How do you do that type of thing in modern C? I.e. define a struct with a pointer to a function that takes a pointer to a struct you're defining.

Name: Anonymous 2013-07-15 9:38

Just define another struct that will hold the function pointers inside this struct.

Name: Anonymous 2013-07-15 9:39

>>1
WHAT_THE_FUCK_AM_READING.png

typedef struct {
 char* function_caller = NULL ;
} pointer;

char dereference_pointe (pointer*){
 //some code
}

Name: Anonymous 2013-07-15 9:42

>>3
png is pig disgusting, use tga

Name: Anonymous 2013-07-15 9:53

>>4
.png has quality and high compression. I can careless for a lossless raster format. It was also supposed to be a joke. Most of my images are .gif.

Name: Anonymous 2013-07-15 13:18

Name: Anonymous 2013-07-15 13:31

>>6 cool lol

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