Professional Documents
Culture Documents
Assignment
Assignment
Tag: part
Member 1: name (a character array of 20 elements)
Member 2: id (an integer)
Member 3: cost (an 8 byte floating point number)
Member 4: num_available (an integer)
NOTE 2: When you make a new project with given skeleton code, it WILL NOT compile! You have
to declare this structure in tasks.h for it to compile successfully!
A character string 'name' (if the input string is larger, the member 'name' should be set
as an empty string).
An integer 'id'
A floating point number 'cost'
An integer 'num'
Your function should return a structure variable (of type struct part) initialized with this data.
The function prototype is given below:
struct part load_data(char * name, int id, double cost, int num);
The function should return the address of the nth element (a pointer to the nth element) or NULL
if the list contains less than n elements.
The structure used for creating the list (in this task and Task 5) is declared as follows:
struct node
{
int data;
struct node * next;
};
The structure used for creating the list in this task, is declared as follows:
struct list_node
{
struct part data;
struct list_node * next;
};
The data part of this structure is the structure that you have already seen in tasks 1 to 3.