| | |
dynamic memory allocation in a struct
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Oct 2007
Posts: 305
Reputation:
Solved Threads: 43
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;
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 1:04 am.
![]() |
Similar Threads
- Memory Allocation of a Struct (C++)
- Help with function (C++)
- deleting dynamic memory (C++)
- Double-linked list in contiguous memory. (C)
- Dynamic Memory Allocation (C)
- Linked List problem (C)
- Dynamic Array, Writing to CSV, Floating Point ?'s (C)
- How to delete a data structure in Builder 6.0? (C++)
- how to increase the size of an array? (C)
Other Threads in the C Forum
- Previous Thread: getimage and putimage funtions
- Next Thread: linked lists
Views: 2004 | Replies: 10
| Thread Tools | Search this Thread |
Tag cloud for C
#include * append array arrays asterisks binarysearch calculate changingto char character cm command copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic execv feet fgets file fork forloop framework function functions givemetehcodez grade graphics gtkwinlinux hacking histogram homework include incrementoperators input intmain() iso kernel keyboard km lazy license linked linkedlist linux list lists locate logical_drives looping loopinsideloop. lowest matrix microsoft mqqueue mysql number oddnumber odf opensource overwrite owf pdf performance pointer pointers posix problem probleminc process program programming radix recursion recv recvblocked research reversing scanf scripting segmentationfault sequential socket spoonfeeding standard string student systemcall testing threads turboc unix user variable wab whythiscodecausesegmentationfault windowsapi





