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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


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.
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

729 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