Discover the answers to your questions at Westonci.ca, where experts share their knowledge and insights with you. Discover in-depth answers to your questions from a wide network of experts on our user-friendly Q&A platform. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform.

Suppose we define a WaitlistEntry as follows:

typedef struct{
int iPriority; /* Priority of the student to be enrolled */
int iStudentID; /* ID of the student */
}
WaitlistEntry;

Below are different implements of a function to create a WaitlistEntry from given iPriority and iStudentID data. Some of these implementations are flawed. Identify them and describe what is wrong with them briefly:

WaitlistEntry createWL( int iPriority, int iStudentlD )
WaitlistEntry w,
w.iPriority iPriority;
w.iStudentlD iStudentlD;
return w;

a. correct
b. incorrect, leaks memory
c. incorrect, syntax error
d. incorrect, data will be overwritten by next function call

Sagot :

Answer:

You have syntax errors, but I don't know if it happened when you posted this question, nevertheless

Explanation:

Correct code:

WaitlistEntry createWL( int iPriority, int iStudentID ) { // Opening Brace

WaitlistEntry w; // Should be ; not ,

w.iPriority = iPriority;   // Assign Missing

w.iStudentID = iStudentID; // Assign Missing

return w;

} // Closing Brace

// Also note: iStudentID this actually has an 'l' which is LD. Not ID, this is why I assume these errors happened when posting the question.