| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello,
I am having trouble with creating a very basic program to handle an employee record for a hospital, it is supposed to contain the employee number, the name, their department and their age. I have been given this code so far: ------------------------------------- PHP Code:
----------------------------------------- but I am not sure where to go with it after this, as in how to input the information and to sort it by employee number... If anyone can help, or atleast point me in the right direction I would be extreemly greatful. Thanks, --Sean Sandy btw.... here is the assignment, if what I have done so far makes no sense... http://www.trentu.ca/~rhurley/cours...pet/w05ass3.pdf |
|
#2
|
|||
|
|||
|
Regarding feeding of info:
you need to assign valuelike this : hospital->head->data.empnum = Constant Basically you structure is composed of substructures. In other words, each node of is a linked list by itself. This is a case of multiple dimension link list analogous to multidimensional arrays. So for assigning "next" or pointer field of your node, it depends on you whether to form link list of link list. Clear? and the next node as : |
|
#3
|
|||
|
|||
|
Ok, sounds good, do I use:
printf("Instert Info"); scanf("%i" num); hospital->head->data.empnum = num; to allow the user to input the information? --Sean Sandy |
|
#4
|
|||
|
|||
|
Quote:
Yes, but little problem in scanf. it should be scanf("%d",num); else you'll be greeted by errors. |
|
#5
|
|||
|
|||
|
Off course you understand that every new employee must be added to the list, right?
I mean, it's not allways added at the hospital->blabla->data.xxx !You will have to reserve some memory space for the structure of a new employee in the process and link it to the list.... Sounds obvious...but I got the impression that somehow it was not what you where going to do! Good Luck ANibal. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Problem with Entering info into structure (using linked lists) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|