Results 1 to 4 of 4

Thread: Pointer to an array of structures

  1. #1
    Join Date
    Apr 2009
    Posts
    87

    Pointer to an array of structures

    I would like to create a small address book cell. I created a structure with all values accessible to a person then I defined an array of this structure But then I need to use a pointer to a specific case of the table so I thought of two solutions and I want your opinion:

    Code:
     (Individual + i) -> name [n] = 0
    and

    Code:
      individual [i] -> name [n] = 0
    i is the individual pointer to the table structure and it is the position in the table and n is the position in the string name.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: Pointer to an array of structures

    It is this that you want to do?
    Code:
    # include <stdio.h> 
    
      typedef struct 
      ( 
    	  char name [10]; 
    	  char first_name [10]; 
    	  unsigned int age; 
    
      Individual); 
    
      int main (void) 
      ( 
    	  Individual I [5]; 
    
    	  scanf ( "% 9s", I [0]. name); 
    
    	  / * ...  * / 
    
    	  printf ( "% s", I [0]. name); 
    
    	  return 0; 
      )

  3. #3
    Join Date
    Apr 2009
    Posts
    87

    Re: Pointer to an array of structures

    No in fact I try to use a pointer to the table than the value.

  4. #4
    Join Date
    Jan 2009
    Posts
    199

    Re: Pointer to an array of structures

    Code:
    // array of pointers to structs
    link heads[config->m]; 
    
    // make memory for head nodes
    for(n = 0; n < config->j; k++)
      heads[i] = malloc(sizeof(struct node));
    The code works (which is great).

Similar Threads

  1. Changing Stylus pointer to normal Pointer in Tablet PC
    By Kelley in forum Portable Devices
    Replies: 3
    Last Post: 21-06-2011, 07:22 PM
  2. How to use void pointer to generate 2D Array in c++
    By Conraad in forum Software Development
    Replies: 4
    Last Post: 06-02-2010, 05:14 PM
  3. Differentiation between void pointer and null pointer
    By Ram Bharose in forum Software Development
    Replies: 5
    Last Post: 18-01-2010, 12:11 PM
  4. Pointer to an array of pointers
    By pushpendra in forum Software Development
    Replies: 3
    Last Post: 29-12-2009, 12:45 PM
  5. Size of a pointer to an array of char
    By Zool in forum Software Development
    Replies: 3
    Last Post: 14-10-2009, 12:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,513,546.90241 seconds with 16 queries