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

Pointers to Structs?

Name: Anonymous 2010-07-19 16:29

Hey guys, I'm having some trouble with pointers in C++

Lets say we are setting up an SDL surface

SDL_Surface *screen;

Why do we make it a pointer? I looked in the header file for SDL_Video and SDL_Surface is a struct! So that means we are pointing to a struct, but then how are we able to do this?

screen = SDL_SetVideoMode(...);

So yeah my question is basically, how does pointing to a struct work?

Name: Anonymous 2010-07-19 16:43

SDL_SetVideoMode returns a pointer to a struct.

Name: Anonymous 2010-07-19 16:47

the same way pointing to anything works

Name: Anonymous 2010-07-19 16:49

Maybe you shouldn't be trying to use a library like SDL without first understanding how your language works.
Also, learn C before going anywhere near Sepples.

Name: Anonymous 2010-07-19 16:50

>>1
You're a moron.

Name: Anonymous 2010-07-19 16:50

what happens is the magic pixie-goblins in the computer circuit boards and chips etc make it point to a struct

Name: Anonymous 2010-07-19 17:17

>>4
I know how to program C, I've just never had to make a pointer to a struct

>>2
Thanks for actually giving me a straight answer

Name: Anonymous 2010-07-19 17:22

>>7
I know how to program C, I've just never had to make a pointer to a struct
No you don't. You really, really don't.

Thanks for actually giving me a straight answer
What the fuck did you expect was going on there? Jesus fucking Christ.

Name: Anonymous 2010-07-19 17:26

head on over to cavern of cobol

Name: Anonymous 2010-07-19 17:27

>>8
>What the fuck did you expect was going on there?
I didn't expect anything, I wouldn't have asked if I did

Name: Anonymous 2010-07-19 17:31

>>1
It would be the same as saying

struct *screen { /* Contents of SDL_Surface */ };

Name: Anonymous 2010-07-19 17:31

>>10
Next time, try reading the fucking documentation and learning the language you're trying to use before annoying anyone with brain-dead questions like these.

Name: Anonymous 2010-07-19 17:33

>>11
But then how are you able to declare a function on that?

Name: Anonymous 2010-07-19 17:36

>>13
Because SDL_SetVideoMode() is an extern, not a function...

Name: Anonymous 2010-07-19 17:46

DON'T HELP HIM

Name: Anonymous 2010-07-19 17:47

YHABT

Name: Anonymous 2010-07-19 17:50

>>14
That doesn't even make sense.

Name: Anonymous 2010-07-19 23:17

>>7
If you don't know about pointers and pointers to structs, you do not know how to program in C. The fact that you do know how this also alludes to the fact that you probably don't know the difference between the program stack and the program heap. You probably barely even know about malloc and free and dynamic memory management.

Name: Anonymous 2010-07-20 4:16

Yeah, pointers and structs are kindof fundamental to C. You can't not know what a "pointer to a struct" is and still call yourself a C programmer.

Also, /prog/ is a terrible place to ask questions like this, because you're going to get nothing but trolls with fake advice (e.g. most of this thread.)

Name: Anonymous 2011-02-03 7:33

Name: Anonymous 2011-02-18 13:07

check my doublesNewer Posts
Don't change these.
Name: Email:
Entire Thread Thread List