以下のコードでは、「root」が指す「netAddr」は put を出力しますが、「pointer.」が指す「maskAddr」は出力しません。よろしくお願いします。最後の手段としてお願いします。「netAddr」の値は表示されますが、「pointer」が指すものは表示されません。
struct RouteInfo
{
unsigned long netAddr;
unsigned long gateAddr;
unsigned long maskAddr;
char ifName[IF_NAMESIZE];
int metric;
int ttl;
struct RouteInfo *next;
};
struct RouteInfo *root; /* This will be the unchanging first node */
/* This will point to each node as it traverses the list */
struct RouteInfo *pointer;
//allocating space for the root
root = malloc(sizeof(struct RouteInfo));
root->next = 0;
root->netAddr = 19216811;
//Point to 1st Item
pointer = root;
/* Creates a node at the end of the list */
pointer->next = malloc( sizeof(struct RouteInfo) );
pointer = pointer->next;
pointer->maskAddr = 25525500;
pointer->next = malloc( sizeof(struct RouteInfo) );
pointer = pointer->next;
pointer->gateAddr = 19216810;
pointer->next = malloc( sizeof(struct RouteInfo) );
pointer = pointer->next;
strcpy(pointer->ifName, "eth1");
pointer->next = malloc( sizeof(struct RouteInfo) );
pointer = pointer->next;
pointer->metric = 16;
pointer->next = malloc( sizeof(struct RouteInfo) );
pointer = pointer->next;
pointer->ttl = 30;
//marking the last as NULL
pointer->next = 0;
//Pointer points to root again
pointer = root;
printf("%lu%lu \t",root->netAddr, pointer->maskAddr);