Murtan 317 Practically a Master Poster

Please use code tags when posting code, preferably the language-specific version so we get syntax highlighting. It makes the code MUCH easier to read.

If you want the linked list to be ordered by last name, the convention is to put the record in the list where it belongs.

If the first record added is for "James Smith" then it is the only record. If we now want to add a record for "Bill Wilson", it should be added after "James Smith". If we then add a record for "Carol Fisher" if goes before "James Smith". Repeat as additional records are added and the list will always be sorted by last name.

So the code ends up looking something like:

// preinitialize the new record's next to null
newstudent -> next = null;

student_list * prev = null;
student_list * curr = head;
// while there are more records to look at on the list
while (curr != null)
{
   // should the new record come before the 'current' record in the list?
   if (strcmp(newstudent -> Last_Name, curr -> Last_Name) < 0)
   {
      newstudent -> next = curr;
      break
   }
   prev = curr;
   curr = prev -> next;
}

if (prev == null)
   head = newstudent
else
   prev -> next = newstudent
Salem commented: Better copy/paste the "please use tags" phrase to a hot key, you need it a lot at DW +24
Murtan 317 Practically a Master Poster

LPT1 is a device, you are unable to open it to read what someone else has written (or will write) to it, it just doesn't work that way.

To do what you are proposing, you would need to somehow 'get between' the other application and the output device. You could then log the characters the other application sends and forward them to the device.

Murtan 317 Practically a Master Poster

Your loop starting on line 129 is only one line long (130)

You should probably also indent lines 131 to 147 to the same level as 130 to make them part of the loop.

Murtan 317 Practically a Master Poster

As a side note to the discussion, although it is convenient in this context to have the default Car constructor generate a random car, the constructor seems to be doing an awful lot, including adding delays?

I try to promote the simple constructor theory where the constructor is as simple as possible and very rarely has problems.

It would be a better design to pull the random generation out and move it to a stand-alone function that would create a Car with 'random' attributes.

Is there any real benefit (either to the class or the program) to have several random delays in the single constructor method?

ddanbe commented: I could not have said it better +2