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?
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.
>>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:
Anonymous2010-07-19 17:33
>>11
But then how are you able to declare a function on that?
Name:
Anonymous2010-07-19 17:36
>>13
Because SDL_SetVideoMode() is an extern, not a function...
>>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.
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.)