#include // From the previous example: enum skyColor {blue, orange, gray} skyColorType; struct forecastInfo { double temperature; char *message; char *city; }; // Structure of each list node: struct ListNode { struct forecastInfo fInfo; struct ListNode *next; }; // The list's front and rear pointers: struct ListNode *front = NULL; struct ListNode *rear = NULL; // Add a new node to the rear of the list. void add (char *city, double temp, char *message) { struct ListNode *listPtr = (struct ListNode *) malloc (sizeof (struct ListNode)); // Fill data. listPtr->fInfo.city = city; listPtr->fInfo.temperature = temp; listPtr->fInfo.message = message; listPtr->next = NULL; if (front == NULL) { // If list is empty, front and rear point to same node. front = rear = listPtr; return; } // Otherwise, we know there's at least one element, so // add the new node past the current rear node. rear->next = listPtr; rear = rear->next; } void printList () { struct ListNode *listPtr; printf ("List :\n"); // Start at the front and walk through the list. listPtr = front; while (listPtr != NULL) { // Process current node. printf (" Forecast for %s: temperature=%lf %s\n", listPtr->fInfo.city, listPtr->fInfo.temperature, listPtr->fInfo.message); // Move on to next node. listPtr = listPtr->next; } } int main () { add ("DC", 85.6, "Hot"); printList (); add ("LA", 72.6, "Warm"); printList (); add ("NY", 64.6, "Cool"); printList (); }