pointer tutorial ???

Posted on 2001-06-12
Last Modified: 2010-04-02

     Could someone explain to me why should I use pointer. Why would I want to know for example the memory adress of a variable (&c1). What's  so impressive about pointer and why should I use them ??????

      Sorry for that long question.
Question by:deschenesp
LVL 86

Expert Comment

ID: 6181573
See and delete this one to have your points refunded...

Expert Comment

ID: 6181629
some of the nice things that you can do with pointers :
as you know, a function can have only one return value. a function cannot, for example, return a success/failure status and at the same time return a 'real' value (calculation result, some kind of string or whatever). you can solve the problem with global variables, but that it ugly and unsafe. with pointers, you can send to a function parameters which are actually addresses of variables, and the function can fill those addresses with data, which you can read later, when the function returns. so you have multiple returned values from a function.

another thing is scanning arrays - doing it with a pointer is faster than doing it with indexes.

a third thing is passing structs as parameters to functions. a struct 9or an object in C++) may be very large, and passing it by value will catch a lot of memory on the stack. passing a pointer is no more than 2/4 bytes...

and a very important usage of pointers is the dynamic allocation of arrays. you do not always know in advance the size of an array that you will need (for example - an array to hold the grades of students in a class. you don't know the number of students that will be when the program is run. if you 'hard code' an array of a specific it will probably be too big - memory wasted or too small - not enough room for all grades). with a pointer and a dynamic allocation during run-time you solve the problem.

there are many more reasons, but maybe you are already aware of the importance of pointers.
LVL 14

Expert Comment

ID: 6181794
Write your EMail and I 'll send you Pointer tutorial

Expert Comment

ID: 6181801
For a tutorial on pointers check and look in the tutorials section

Expert Comment

ID: 6181868
All information is here:

Keep following things in mind while learning pointers whenever u see any expression.

address = address
value = value

and A[i] = *(A + i)
   A[i][j] = *(A[i] + j) = *(*(A+i) + j))
   A[i][j][k] = *(A[i][j] + k)
              = *(*(A[i] +j ) + k))
              and so on.......

Thanks and Best Regards,
LVL 30

Expert Comment

ID: 6182150
Two of your posted links, are exactly the same.
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

LVL 30

Expert Comment

ID: 6182151
Two of your posted links, are exactly the same.

Expert Comment

ID: 6182180
Thanks Axter,
It is because of 'copy and paste'funda.
The third link is

Expert Comment

ID: 6193153
actually,we dont REALY need pointers,but they make our lives as programmers alot easier.
for ex.:if you have an array of 10 items(or whatever),nad you want to go to each one in any time,you can go by calling the name of the array and adding the place of the wanted item.the NAME of this array,is actually the name you have (unawer)gave to a pointer,who points to the address where this array when you go to the item,you realy go to the X places after the beginning address.
when you dont want to burden(overload,i forgot how to write it) the computer,you can use DYNAMIC memory.this will alow you to move freely around the items,AND(the most important thing!!)-you dont have to know the size of the array at beginning of your program!!
say,you awnt to get some names,but you dont know how many names you are going to can use a dynamic array,and then add each name as you go along.but since you dont realy know where this array seats,you need something to point out to you the starting point of the array,so when you want to do something with these names,you can get to you define a pointer,which you later give a value,and TIHS pointer is the thing that makes you go wherever you want in this array,just as if it was a normal array...
LVL 43

Expert Comment

ID: 6231474
Sorry guys to hijack this thread but deschenesp has a number of outstanding ungraded questions, specifically of interest to me is this has been outstanding for more than 6 months.

deschenesp, failure to maintain your questions may be considered sufficient grounds for suspension of your account. I strongly suggest that you clean up the outstanding questions as soon as possible.
LVL 11

Expert Comment

ID: 6817237
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to refund the points PAQ at zero points since your question was alredy answered in .

The link to the Community Support area is:


Accepted Solution

Netminder earned 0 total points
ID: 6833308
Per recommendation points refunded and question closed.

Community Support Moderator
Experts Exchange

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now