Monday, 15 June 2015

singly linked list - Link another structure in C -


I am trying to make this data stitch in C. Like this:

  structure room {int roomnumber; Structure room * nextroom; Structure person * person list; } * Top = zero, * temporary = zero, top1; Structure person {int personnumber; Structure person * next; } * Node = zero, temp1;  

The person in the structure's room is an indicator for the structure person. I have a difficult time connecting it with any other structure is it right?

This is my job

  Enter zero () {int val; Printf ("Enter Value:"); Scanf ("% d", & amp; val); Newnode = create_node (val); If (top-> gt; person list == tap) {top-> personList = newnode; } And {node-> Next = new node; Node = newnode; }}  

The Insert a person in the room is already built. create_node () is malloc ()

Here is a version that does not use globally, which makes your work more common and Reusable:

  #include & lt; Stddef.h & gt; # Include & lt; Stdlib.h & gt; # Include & lt; Stdio.h & gt; Typedef Structure Person {int personNumber; Structure person * next; } person; / * Note: This is a typingfiff, is not a global declaration such as you * / Type-aff strat room {int room number; Person * person list; Person * final list; Structure room * nextroom; } Rooms; / * Note: This is a typewriter, is not a global announcement, such as you * create * person_with_inter (person) {person * rate = callok (1, size (* ret)); If (rate) {rate-> person number = wal; Rate- & gt; Next = null; } Return return; } Ent Room_Instant (Room * R, Int Val) {person * p = create_person (val); If (pipe == p) returns -1; If (navel! = R-> gt; person list) r- & gt; Last Install & gt; Next = p; Other R- & gt; Personlist = p; R-> Last Initial = P; Return 0; } Int main (int argc, char ** argv) {room my_room = {0}; / * Required! Tap * starts points / rooms my_other_room = {0}; / * Required! Null * / person * initiates points for P; Room_increment (and my_root, 5); Room_Instant (and my_over_room, -5); Room_increment (and my_room, 10); Room_interest (& my_other_room, -10); Room_increment (and my_room, 15); Room_Instant (& my_other_room, -15); For (p = my_room.personList; p; p = p-> Next) printf ("% d \ n", p-> person number); (P = my_other_room.personList; p; p = p-> Next) printf ("% d \ n", p-> person number); Return 0; }  

No comments:

Post a Comment