Tripple pointers

This is a discussion on Tripple pointers within the C Programming forums, part of the General Programming Boards category; Can you help me to start with them I cant find any information about them the exactly thing i need ...

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    24

    Tripple pointers

    Can you help me to start with them I cant find any information about them

    the exactly thing i need its Array of pointers where the pointers are pointing a menu like this idea below.

    Pls just help me with the syntax ...
    Attached Images Attached Images  

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,981
    Personally, what I might do is create a Menu struct. This struct would then have an array (or pointer to the first element of a dynamic array) of MenuCategory objects. Each MenuCategory object would then have an array (or pointer to the first element of a dynamic array) of MenuItem objects. It is each MenuItem object that will contain the string.
    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
    Registered User
    Join Date
    Apr 2010
    Posts
    24
    Ok but my boss gave this one for training and make me learn that triple pointers, so can you help me build that like the picture... I understand what I must do but my problem is the syntax ... can you help me with the syntax ...

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,981
    Quote Originally Posted by westony
    Ok but my boss gave this one for training and make me learn that triple pointers
    Your boss wants you to be a Three Star Programmer?

    Quote Originally Posted by westony
    I understand what I must do but my problem is the syntax ... can you help me with the syntax ...
    Follow my previous suggestion first. Post your attempt. When it is clear that you are capable of doing things in a more sensible way, I'll help you pretend to be a three star programmer.
    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

  5. #5
    Registered User
    Join Date
    Apr 2010
    Posts
    24
    Ok help me how make that
    Code:
     *mainmenu[] = {"menu1", "menu2", "menu3"};
    how to target those menu1,2,3 to those m1p1, m1p2 ... the other is easy game Just do not know how to declare that triple .............

  6. #6
    Registered User
    Join Date
    Apr 2010
    Posts
    24
    Code:
    ***all;
    char *mainmenu[] = {"menu1", "menu2", "menu3", NULL};
    all[0] = mainmenu;
    help its shows me:

    Warning 1 : 'char ***' differs in levels of indirection from 'char **'
    for the last roll ...

  7. #7
    Registered User
    Join Date
    May 2010
    Posts
    74
    Don't forget to allocate memory first.

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    It would be something like
    Code:
    char *mainmenu[] = {"menu1", "menu2", "menu3"};
    char *submenu[] = {"sub1", "sub2"};
    char **all[] = { mainmenu, submenu };
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #9
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,047
    Quote Originally Posted by laserlight View Post
    Your boss wants you to be a Three Star Programmer?
    lol!

  10. #10
    Registered User
    Join Date
    Oct 2006
    Posts
    250
    Quote Originally Posted by laserlight View Post
    Personally, what I might do is create a Menu struct. This struct would then have an array (or pointer to the first element of a dynamic array) of MenuCategory objects. Each MenuCategory object would then have an array (or pointer to the first element of a dynamic array) of MenuItem objects. It is each MenuItem object that will contain the string.
    Why so complicated? Why not just reuse the original Menu struct instead of defining a MenuCategory and MenuItem?

  11. #11
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,981
    Quote Originally Posted by MWAAAHAAA
    Why so complicated? Why not just reuse the original Menu struct instead of defining a MenuCategory and MenuItem?
    You could, but that would allow an arbitrary number of menu levels, which may be contrary to what was described. (That said, a MenuItem abstraction may still be useful.)
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. size of struct with pointers and function pointers
    By sdsjohnny in forum C Programming
    Replies: 3
    Last Post: 07-02-2010, 05:19 AM
  2. Replies: 7
    Last Post: 05-19-2010, 02:12 AM
  3. pointers to arrays
    By rakeshkool27 in forum C Programming
    Replies: 1
    Last Post: 01-24-2010, 06:28 AM
  4. pointers to constants and constant pointers
    By homeyg in forum C++ Programming
    Replies: 1
    Last Post: 06-18-2005, 12:02 AM
  5. Staticly Bound Member Function Pointers
    By Polymorphic OOP in forum C++ Programming
    Replies: 29
    Last Post: 11-28-2002, 12:18 PM

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