pointer with double asterisk

This is a discussion on pointer with double asterisk within the C Programming forums, part of the General Programming Boards category; Is this a pointer to a pointer? The instants is one most should be familiar with. Code: #include <stdio> #include ...

  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
    20,968
    Yes, it is a pointer to a pointer.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,167
    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.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  4. #4
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    602
    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
    20,968
    Quote Originally Posted by slingerland3g
    Did you happen to note how the arguments to main are defined?
    skringla obviously did
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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
    602
    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をこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,167
    Memory Functions - Still Learning
    Pointers
    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.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  9. #9
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    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.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  10. #10
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    489
    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,189
    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
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

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, 03: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, 08: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


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21