Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > pointers to pointers

Reply
Thread Tools

pointers to pointers

 
 
defcon8
Guest
Posts: n/a
 
      10-06-2005
Could someone paste an example of why pointers to pointers could be
needed please?

 
Reply With Quote
 
 
 
 
Eric Sosman
Guest
Posts: n/a
 
      10-06-2005


defcon8 wrote On 10/06/05 14:42,:
> Could someone paste an example of why pointers to pointers could be
> needed please?


Second argument to main().

Second argument to strtod(), strtol(), and so on.

Both arguments to the comparison function called by
qsort(), when you're using it to sort an array of pointers.

--
http://www.velocityreviews.com/forums/(E-Mail Removed)

 
Reply With Quote
 
 
 
 
Alex Fraser
Guest
Posts: n/a
 
      10-06-2005
"defcon8" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Could someone paste an example of why pointers to pointers could be
> needed please?


There are a few standard library functions that use them, eg strtol().

Alex


 
Reply With Quote
 
Alexei A. Frounze
Guest
Posts: n/a
 
      10-06-2005
"defcon8" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Could someone paste an example of why pointers to pointers could be
> needed please?


When you want the called function to modify some variable defined in the
calling function locally (or a global variable), you pass a pointer to that
some variable to the function. It may happen that that some variable is also
a pointer. Example, you may want a function to malloc() a buffer and somehow
return the pointer to it to the caller, yet you cannot return it by return
(if it's for instance used for telling the error code).

If you don't like pointers, try Java. Or even better Basic or Matlab. The
latter don't generally have a good idea of what a pointer/address/reference
is.

But really, there are uses for many things that are possible in the
language. Some things may be misused. Some uses may be unknown to you, but
neither means there shouldn't be such or such feature...

Alex


 
Reply With Quote
 
Mike Wahler
Guest
Posts: n/a
 
      10-06-2005

"defcon8" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Could someone paste an example of why pointers to pointers could be
> needed please?


Same reason you'd need a pointer to any other
type. Pointers are typically used as function
parameter(s) when the function needs to modify
its argument(s). If one of those arguments
has a pointer type, then we need a 'pointer-to-
pointer' parameter.

If you don't need them, don't use them.

-Mike


 
Reply With Quote
 
Dale
Guest
Posts: n/a
 
      10-07-2005
"defcon8" <(E-Mail Removed)> wrote in news:1128624147.466368.32080
@z14g2000cwz.googlegroups.com:
>
> Could someone paste an example of why pointers to pointers could be
> needed please?
>


A dynamic list of dynamic lists.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pointers, pointers, pointers... cerr C Programming 12 04-07-2011 11:17 PM
Does deleting a container of pointers also delete the (contained) pointers? Xamalek C++ 7 11-04-2003 04:17 PM
c++: pointers to pointers A C++ 3 10-29-2003 01:15 PM
pointers to pointers // exception handling error muser C++ 3 09-18-2003 06:19 PM
Template specialization of pointers with function pointers Phil C++ 1 09-16-2003 02:17 AM



Advertisments