• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:


Hello experts,

I have a few question that come across my head when I browse thru a smalll program regarding pointers..

From my understanding a pointer is declare as :
     char *ptr;

but I saw a special case where some programmer declare as :
   char **ptr;

I just hope u can explain to me about this type of pointer what it means and show me some small example (if u can I will appreciate it).


  • 3
  • 2
1 Solution
char **p;  is a pointer to a pointer.  This might help a bit:

char c  this is a byte in memory that stores a char.

char *c  this is a pointer to a memory location where a char resides.  You need to dereference that pointer to access the variable.

char **c  this is a pointer to a pointer to a memory location. You need to dereference this variable twice also.  Keep in mind, this COULD be a pointer to a string(which is a pointer to a block of chars in memory).

If you see it being used in a function call, then it is most likely a pointer to a string.  Many programmers use **c(also known as handles) or single pointers when they want to fill a variable.  So it starts out with blank, the function gets called and when it returns, there is something in there.  So you would declare as follows:

char *String = "";


Hope this helps!

dekoay, do you want article about
pointers? You can get it from
http://www.snippets.org/ (as part
of zip file)
or i can send you (write you EMail)
dekoayAuthor Commented:

Thanks for the explanation regarding this pointer... However, does this only works with gcc compiler(in unix) or this is an ANSI standards ?

However, I'm quite understanding after the exaplnation....

Thanks again

7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

this is an ANSI standard.  I suppose if you got super bored you could do something like this:

char *****c;

and deal with it from there...but don't, or someone will NOT like you're code.  ;-)  Basically, you can add as many pointers to something as you wish(I don't think there's a limit)...

dekoayAuthor Commented:
hello Bud,

Thanx for the conclusion
no problem, it's called earning the points.  =)

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now