| | |
dynamic memory allocation in a struct
Thread Solved |
•
•
Join Date: Oct 2007
Posts: 307
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 12: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: 2295 | Replies: 10
| Thread Tools | Search this Thread |
Tag cloud for C
api array arrays bash behaviour binary binarysearch c++ char character code coke command conversion convert copy copypdffile createcopyoffile database decimal directory dude dynamic ebook error exec factorial fgets file fork function functions givemetehcodez global grade graphics hacking help.forensic homework i/o ide input insert int integer lazy libcurl library line linked linkedlist linux list lists loop malloc matrix memory mysql no-effort number output pass path pointer pointers power printf problem process program programming read recursion recursive recv research reverse roman scanf sequential sms_speak socketprograming spoonfeeding steganography strchr string strings strtok structures student system test turbo-c turboc unix user variable windows words





