sushmita upadhaya wrote:
> > I study to become softwaree enginner and i learn at
> > the moment C for the firdt semester!We learn to use
> > pointers but with the instructions of the proffesor
> > i didn't understand the very well.So please tell
> > what pointers do and why to use them even if they
> > make my life diffucult?
In many cases you would like to use "normal" variables like:
Example:
int x;
However, in practice it is often difficult to predict the number of
variables you will have to proces. How many lines will there be in a
book that you scan? How many record are there in an email addreslist?
In such cases you may want to work with "dynamic" memory. Then you need
those pointers to be able to find and retreive the data in/from the
computers memory.
Another advantage of pointers:
In stead of moving huge amounts of data in function calls it is often
faster to use a pointer to the data.
Example:
int x[100000];
int main() { my_function(x); } // Huge memory and time needed.
int main() { my_function(&x); } // Very fast and efficient
Hope this helps
|