dynamic memory allocation in a struct

Thread Solved

Join Date: Oct 2007
Posts: 307
Reputation: stilllearning has a spectacular aura about stilllearning has a spectacular aura about 
Solved Threads: 43
stilllearning stilllearning is offline Offline
Posting Whiz

Re: dynamic memory allocation in a struct

 
0
  #11
Sep 25th, 2008
paths is a pointer, as per your definition.

path_info *paths

When you do

global_routing_info[i].paths = (path_info *) malloc ( sizeof ( path_info ) );

You now have an array of paths.

In order to access an element of path using the array notation [], you need to use the . not the ->

So its
global_routing_info[neighbor].paths[no_paths].path_id = path;

not

global_routing_info[neighbor].paths[no_paths]->path_id = path;
Last edited by stilllearning; Sep 25th, 2008 at 12:04 am.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 2295 | Replies: 10
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC