A point could point to anything (reference anything), that could be a pointer to an object of a class , a pointer to a structure, a point to int, to char … to anything actually. A managed environment means that your J VM or .net CLR, takes care of a lot of things for you…
this is the declaration, it doesn’t point to anything now… in other languages, if you tried to use this pointer it will throw an exception , in c it wont it will simply get you the value that originally existed in the place you are pointing to… and if you attempted to write to it, you will overwrite someone else’s data or in best cases you will write in a random place where no one knows if it is used or not.
an important usage of the pointer is passing a variable by reference if we have a function as follows: In c an array is a pointer to the first element of the array. The point here is the dynamic allocation... Note: add the lib where the function malloc exist in malloc.h Nothing will happen, we have changed what the pointer “par” points to not what the original array points to…
For this to work, we need to make a pointer to pointer…
That will change the value of ar… Thus we could do the following to the function:
That’s all… my goal was to overview the pointers briefly… you will have some long book in the c to get it all but this is the short version… Thank you.
Comments
Hi, Great work, I
Hi,
Great work, I modified it a bit to improve the code formating :)
I had a question though, do we need all the inter-language talk? I find it a bit confusing and distracting.
What do you think ?
Pointers are _NOT_
Thanks for the feedback
Thanks for the feedback, I have made some enhancements with your comment.