This article was for Java language but it may be helpful for you. just for educational purpose.
Why Pointers are Important in Java?
We usually use pointers simply as a reference to another variable in our programs. Well, for such cases, you can say that there is no need to expose memory addresses and a programming language will do fine with just references (as Java does) .In our whole programing we use the pointers. A struct is a pointer, an array is a pointer, a string is a pointer and a class is a pointer even a variable is a pointer which points his value. Pointers are necessary for dynamic memory location, many data structures, and efficient handling of large amounts of data. Also, pointers are useful for Efficiency. If you pass ten thousand ints to a Function, you will have a substantial Time penalty, unless you pass a Pointer to an array of ten thousand ints. Pointers can be faster and can incur less overhead, both in data structures and in keeping the program execution footprint down. Pointers are not there only for referencing existing variables. They are there to support direct interactions with hardware. That's a must for any systems programming language as without pointers you are unable to write a device driver. For example, if you want to read data from a device in your program, you need to instruct the device to write n bytes in address a. Because of that, you need a data type that can store addresses and an operator that returns the address of a variable.
What are precautions while using pointers?
Use a valid name while declare the pointer.
Always initialize pointer variable.
Set the pointer NULL after use for free the memory.
This is the best to initialize all pointers to null.
Release the memory once you are done with it.
Send your Question file at: email@example.com
38 problems solve in a day
We had seen many YouTube videos and articles that copy our sources. We don’t allow to anyone to use our code and sources for their personals or business use. Our all sources like programing codes and demos are only for educational purpose because we are educators not businessman. If we found any other copy issue we will contact with YouTube for block your channel.