pntr to struct in struct

This is a discussion on pntr to struct in struct within the C Programming forums, part of the General Programming Boards category; hi everyone, I need some examples of using "pointer of struct inside another struct" Thank you kindly...

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    27

    pntr to struct in struct

    hi everyone,
    I need some examples of using
    "pointer of struct inside another struct"

    Thank you kindly

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Code:
    struct node {
           char data[128];
           struct node *ptr;
    };
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    A small note. If in case you need to typedef that struct, you do something like:
    Code:
    typedef struct node nodeTag {
           char data[128];
           struct nodeTag *ptr;
    } node;
    
    //example
    node myNode;

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,612
    Quote Originally Posted by C_ntua View Post
    A small note. If in case you need to typedef that struct, you do something like:
    Code:
    typedef struct node nodeTag {
           char data[128];
           struct nodeTag *ptr;
    } node;
    
    //example
    node myNode;
    Code:
    typedef struct node
    {
           char data[128];
           struct node* ptr;
    }
    node;
    
    //example
    node myNode;
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Segfault with Linked List Program
    By kbrandt in forum C Programming
    Replies: 1
    Last Post: 06-23-2009, 07:13 AM
  2. Global Variables
    By Taka in forum C Programming
    Replies: 34
    Last Post: 11-02-2007, 03:25 AM
  3. Replies: 10
    Last Post: 05-18-2006, 11:23 PM
  4. What's wrong with my search program?
    By sherwi in forum C Programming
    Replies: 5
    Last Post: 04-28-2006, 09:57 AM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 02:58 PM

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