Originally posted by Girby2K11
yeah like the pointers they are pissing me off, but i will re visit it
I can help you understand pointers, they are a very easy to understand once you have been taught properly what they really are.
Ok, so you probably understand the concept of memory addresses and the fact they store data, but sometimes when explaining pointers, some tutorial kind of forget to highlight the key features of a pointer that make it difficult to understand.
To start, when declaring a pointer,
int myNumber;
int *intPointer;
bool myBool;
bool *boolPointer
Now, the pointer here is not a integer value, or a boolean value, they are actually a data type of pointer it self, all int *pointer means is, here, i have a pointer data type called intPointer, and when you point, you are pointing at a data type of a integer. now wait a second, what does, pointing at a data type of int really mean?
When pointing at a int, you are telling the computer, to look at memory location #, but remember, and integer is 4 bytes big, so it will have to look at the next 4 memory locations to get the data required to make up an integer, the same for a boolean pointer, it will only look at one byte (boolean size).
How to use pointers.
Try to think of a pointer as a location data type, it can only store a location.
int myNumber = 50;
int *myPointer;
myPointer = &myNumber;
//& sign translates to, "Memory address of: "
*myPointer = 100;
//* Translates to, "Value of address: "
if(myNumber==100)
//This statement now is true