Thread: Array of pointers

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    8

    Array of pointers

    How to pass an array of pointers to a function?
    Please help me....

  2. #2
    Registered User
    Join Date
    Feb 2006
    Posts
    155
    **pointer

  3. #3
    Registered User
    Join Date
    Mar 2006
    Posts
    8

    Thanks for your reply

    but i have got another doubt:
    I have two functions f1 and f2.
    f1 has a structure defined in it.(this structure is local to f1)
    Now how do i pass this structure to f2.

    Code:
    Code:
    f1()
    {
    
                 typedef struct Node  { 
    	     char Value [128]; 
    	     char Value2 [128];
    	struct Node *next; 
                  } listNode; 
    
                 listNode* HashTable[HASHSIZE];
    
               f2();//Now how to pass this structure to f2
    }

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,665
    > How to pass an array of pointers to a function?
    Same as an array of any other type.

    > f2();//Now how to pass this structure to f2
    f2( HashTable );
    would be good, where

    void f2 ( listNode* HashTable[] );
    Is the prototype of the function
    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.

  5. #5
    Registered User
    Join Date
    Mar 2006
    Posts
    8
    Hi ,
    Thanks for your reply...
    But i get a complier error at the place where f2(listNode * HashTable[HASHSIZE]) is defined.

    The error is :
    syntax error before listnode;


    Please help me out....
    Thanks in Advance

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You're declaring your structure inside a function. Don't.


    Quzah.
    Hope is the first step on the road to disappointment.

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,665
    Sorry, I can't extrapolate your entire code from 1 error message.

    > syntax error before listnode;
    Maybe you're missing a ; or a closing brace
    Or you're trying to declare/define the function before you declared listnode
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Returning an Array of Pointers to Objects
    By randomalias in forum C++ Programming
    Replies: 4
    Last Post: 04-29-2006, 02:45 PM
  2. two-dimensional dynamic array of pointers to classes
    By Timo002 in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 06:18 AM
  3. Passing pointers between functions
    By heygirls_uk in forum C Programming
    Replies: 5
    Last Post: 01-09-2004, 06:58 PM
  4. array of pointers to struct array
    By eth0 in forum C++ Programming
    Replies: 1
    Last Post: 01-08-2004, 06:43 PM
  5. array of pointers to structs
    By stumon in forum C Programming
    Replies: 7
    Last Post: 03-24-2003, 07:13 AM