pointers to things in nodes (or dumb arsed question number two)

This is a discussion on pointers to things in nodes (or dumb arsed question number two) within the C++ Programming forums, part of the General Programming Boards category; ok, so heres one i just don't know (and don't have enough time to crash test my pc to find ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    48

    pointers to things in nodes (or dumb arsed question number two)

    ok, so heres one i just don't know (and don't have enough time to crash test my pc to find out)

    if you have a variable in a node in a list how do you get a pointer to that variable...for example:

    Code:
    struct node
    {
      int      number;
      node  *next;
    };
    
    node *list;
    new list = node;
    i know to get to number its

    Code:
     int localStorageForNumber
    localStorageForNumber = list->number;
    but how would you get &number?
    i've tried
    Code:
    int *pointerToNumber
    
    pointerToNumber = &list->number
    but i don't think its working because i'm getting access errors later on in code that relied on the above.

    thanks,
    astride a storied past, thats everywhere you are

  2. #2
    looking for the truth moemen ahmed's Avatar
    Join Date
    Feb 2002
    Location
    Egypt
    Posts
    161
    here we go ,hoping it ll help you
    Code:
    #include <stdio.h>
    #include<iostream.h>
    int main(int argc, char *argv[])
    {
      struct node{
             int no;
             node *next;
             }   ;
      node myNode;
      int *pt=&(myNode.no);
      cout<<pt;
      int i;
      cin>>i;
      return 0;
    }
    Programming is a high logical enjoyable art for both programer and user !!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointers Question
    By HAssan in forum C Programming
    Replies: 2
    Last Post: 09-08-2008, 11:17 AM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 01:52 PM
  4. Question about pointers
    By maxhavoc in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2004, 01:46 AM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM

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