C Project Code
C Project Code
h>
#include <stdlib.h>
#include <string.h>
#define MAX_NAME_LENGTH 50
#define MAX_CLASS_LENGTH 20
#define FILENAME "passengers.csv" // Filename set to passengers.csv
// Determine which category the passenger belongs to and set the insert head
if (strcmp(p.category, "senior") == 0) {
insert_head = &headers->senior_head;
} else if (strcmp(p.category, "woman") == 0) {
insert_head = &headers->woman_head;
} else if (strcmp(p.category, "other") == 0) {
insert_head = &headers->other_head;
} else {
return; // Invalid category, do not insert
}
if (temp_node != NULL) {
*head = temp_node->next;
p = temp_node->passenger;
free(temp_node);
}
return p;
}
char line[256];
while (fgets(line, sizeof(line), file)) {
Passenger p;
fclose(file);
return 1; // Success
}
return 0;
}