Thread: pointer with double asterisk

  1. #1
    Registered User skringla's Avatar
    Join Date
    Nov 2008
    Posts
    8

    pointer with double asterisk

    Is this a pointer to a pointer? The instants is one most should be familiar with.

    Code:
    #include <stdio>
    #include <string>
    
    int main(int argc, char** argv)
    {
         int i;
         for(i = 0; i < argc; i++)
         {
              printf("%s\n", argv[i]);
         }
         return 0;
    }
    is argv a pointer to a pointer?
    is there such a thing as a pointer to a pointer?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,412
    Yes, it is a pointer to a pointer.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Well, it's a pointer to char*, and what is char*? Well, it is a pointer to char... so that makes it pointer to pointer to char... doesn't it?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    603
    This technique is very useful to point to an array element of which contains a string. Did you happen to note how the arguments to main are defined?

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,412
    Quote Originally Posted by slingerland3g
    Did you happen to note how the arguments to main are defined?
    skringla obviously did
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    603
    Quote Originally Posted by laserlight View Post
    skringla obviously did
    My bad, sorry skringla!

  7. #7
    Registered User skringla's Avatar
    Join Date
    Nov 2008
    Posts
    8
    Thats all right. I am still trying to grasp the hole pointer concept. I don't completely understand it and every time I think I do the techniques I think would work with pointers don't compile. I am fine working in a system of pointers that is already built (like gtk toolkit) but when I try to build a system for my self it just doesn't work. I will have to go over the tutorials again, but no one seems to be able to explain the things with out making it confusing. At least I have some working knowledge of them at this point.

  8. #8
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    http://cboard.cprogramming.com/showp...3&postcount=31
    http://cboard.cprogramming.com/showp...65&postcount=4
    Two analogies that might help.
    Pointers are really simple. Everything left to the * is the type it points to.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    or seen another way its a pointer to an array of pointers, or an array of pointers, it all depends on what it is ultimately pointign too, but yes, its a pointer to a pointer.

  10. #10
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    587
    Here's a good pointer video for beginners:
    http://cslibrary.stanford.edu/104/
    Not everything that can be counted counts, and not everything that counts can be counted
    - Albert Einstein.


    No programming language is perfect. There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes.
    - Herbert Mayer

  11. #11
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Quote Originally Posted by stevesmithx View Post
    Here's a good pointer video for beginners:
    http://cslibrary.stanford.edu/104/
    Lol, I love the part where binky tries to use his magic wand of dereferencing on an unassigned pointer. Makes me want to teach C/C++ in high school just so I can show that video

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  2. Copying 2-d arrays
    By Holtzy in forum C++ Programming
    Replies: 11
    Last Post: 03-14-2008, 03:44 PM
  3. C++ to C Conversion
    By dicon in forum C Programming
    Replies: 7
    Last Post: 06-11-2007, 08:38 PM
  4. need some help with last part of arrays
    By Lince in forum C Programming
    Replies: 3
    Last Post: 11-18-2006, 09:13 AM
  5. Help with multi function progam
    By WackoWolf in forum C Programming
    Replies: 22
    Last Post: 10-13-2005, 02:56 AM

Tags for this Thread