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

pointers in C

Name: Anonymous 2006-11-02 15:00

I have a little problem. way back in high school I took java, and never had to deal with these little things. now, at college, they're making me take C. I don't have anything against it, its just that.. well I'm not entirely sure what pointers are used for, or what they accomplish. would anyone care to elighten me?

Name: Anonymous 2006-11-03 12:22

Pointers in a nutshell:

- Pointers contain the memory location of a variable, rather than the value of the variable itself.
- Pointers have types (i.e., there are int pointers, float pointers, struct WHATEVER pointers, class WHATEVER pointers)
- There are even void pointers.
- Pointers can be assigned to each other, added to, and subtracted from.
- You can "deference" a pointer to get the value that it's pointing to.
- When you don't want a pointer to point to anything, set it to 0.
- Deferencing a 0 or null pointer generally has bad consequences.
- Array notation is just a different style of pointer notation, i.e., array[7] = *array + 7.  Pointer notation is faster.
- You can get a pointer to a function using pointer syntax.  It's a void pointer.
- Yes, you can even call functions via pointers, like *funcpointer(arg,arg,arg...)
- Yes, you can have an array of void pointers and use them to call functions
- Yes, you can have pointers to pointers and pointers to pointers to pointers.  Linked lists, do you use it motherfucker.


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