const int echoPin=2;
int ledPin1=3;
int ledPin2=4;
int ledPin3=5;
const int trigPin=11;
bool ledActivated=false;
unsigned long ledActivationTime=0;
void setup()
{
Serial.begin(9600);
pinMode(echoPin,INPUT);
pinMode(trigPin,OUTPUT);
pinMode(ledPin1,OUTPUT);
pinMode(ledPin2,OUTPUT);
pinMode(ledPin3,OUTPUT);
}
void loop()
{
if(!ledActivated)
{
digitalWrite(trigPin,LOW);
delayMicroseconds(2);
digitalWrite(trigPin,HIGH);
delayMicroseconds(10);
digitalWrite(trigPin,LOW);
unsigned long duration=pulseIn(echoPin,HIGH);
unsigned long distance=duration/58;
Serial.print("Distance:");
Serial.print(distance);
Serial.println("cm");
if(distance<50)
{
digitalWrite(ledPin3,HIGH);
Serial.println("Heavily Crowded");
ledActivated=true;
ledActivationTime=millis();
}
else if(distance<100)
{
digitalWrite(ledPin2,HIGH);
Serial.println("Moderately Crowded");
ledActivated=true;
ledActivationTime=millis();
}
else
{
digitalWrite(ledPin1,HIGH);
Serial.println("Less Crowded");
ledActivated=true;
ledActivationTime=millis();
}
}
else
{
if(millis()-ledActivationTime>=2000)
{
digitalWrite(ledPin1,LOW);
digitalWrite(ledPin2,LOW);
digitalWrite(ledPin3,LOW);
ledActivated=false;
}
}
delay(1000);
// Name and Date Records
// 1. Learning Objectives
// Analyze source codes written by other programmers
// Use pointers to structures, pointers to strings, and dynamic memory allocation
// Apply modularization
// ※Recommendation: Use enumerations and type definitions when applicable
// 2. Exercise Summary
// An existing program with its provided source code, called “EntSrt.c”, prompts the user to enter consecutively some five names of persons then display them in alphabetical order. Modify the said program into “StrPtrEntSrt.c” so that the date of birth of each person can also be entered and become part of the record that is then displayed by the program in alphabetical order according to the names.
// 3. Exercise Specifications
// a) Process Specifications
// Use a structure whose members are a pointer to the name, and a date of birth.
// As in the previous program, the name string uses an array of characters whose length is only as long as the number of characters input for each name, but not exceeding 10 characters.
// The date of birth should be of type long and uses YYYYMMDD format
// Store the records in an array of pointers to the structure
// Use malloc() to allocate memory for each record
// Use malloc() to allocate memory for each entered name
// Accept user’s input for the respective fields of the record, and like previous program, 5 records can be consecutively entered by the user, and are displayed after each entry
// Sort the records alphabetically according to names
// Display the sorted records and free the allocated memories for the names and structures. Note that freeing the structure may not mean that its dynamically allocated fields are also freed.
////////#include <stdio.h>
////////#include <stdlib.h>
////////#include <string.h>
////////#include <assert.h>
////////#include <stdbool.h>
////////#define maxLength 11
////////#define maxCount 5
//////////NBV2.4
////////typedef char* STRING;
////////bool isValidDate(const char* dateStr);
////////int main()
////////{
//////// // Variables
//////// int count = 0;
//////// STRING names[maxCount];
//////// STRING birthdays[maxCount];
//////// char nameInput[maxLength];
//////// char birthdayInput[9];
//////// STRING intro = "Records Entry and Sorting Program\nPlease input name and birthday (max: 5 entries).\n";
//////// STRING nameInputPrompt = "Name (First Last): ";
//////// STRING birthdayInputPrompt = "Birthday (YYYYMMDD): ";
//////// STRING nameTemplate = " %-10s %-8s Entry count: %2d malloc-address: %p -> %p\n";
//////// STRING sortedNamesTitle = "\nSorted Records:\n";
////////
//////// int length = 0;
//////// char c;
//////// static int error = 0;
//////// int i;
//////// int j;
//////// STRING temp;
////////
//////// // Intro Template
//////// printf("%s", intro);
////////
//////// // Get names and birthdays
//////// while (count < maxCount && !error)
//////// {
//////// printf("%-10s", nameInputPrompt);
//////// length = 0;
//////// fflush(stdin);
//////// // Get name
//////// while ((c = getchar()) != '\n')
//////// {
//////// if (length < maxLength - 1)
//////// {
//////// nameInput[length++] = c;
//////// }
//////// }
//////// nameInput[length] = '\0'; // Null-terminate the string
////////
//////// if (strlen(nameInput) == 0) {
//////// printf("Incorrect name format.\n");
//////// error = 1;
//////// break;
//////// }
////////
//////// else if (!strcmp(nameInput, "0")) {
//////// printf("name error");
//////// error = 1;
//////// break;
//////// } else {
//////// names[count] = malloc(strlen(nameInput) + 1); // Allocate memory for the name
//////// assert(names[count] != NULL);
//////// strcpy(names[count], nameInput);
////////
//////// // Get birthday
//////// do {
//////// printf("%s", birthdayInputPrompt);
//////// scanf("%8s", birthdayInput);
//////// if (strlen(birthdayInput) == 0) {
//////// printf("Incorrect date format.\n");
//////// break;
//////// }
//////// } while (!isValidDate(birthdayInput));
////////
//////// birthdays[count] = malloc(9); // Allocate memory for the birthday (YYYYMMDD)
//////// assert(birthdays[count] != NULL);
//////// strcpy(birthdays[count], birthdayInput);
////////
//////// printf(nameTemplate, names[count], birthdays[count], count + 1, (void *)names[count], (void *)birthdays[count]);
//////// count++;
//////// }
//////// }
////////
//////// if (!error) {
//////// // Bubble sort
//////// for (i = 0; i < count - 1; i++) {
//////// for (j = i + 1; j < count; j++) {
//////// if (strcmp(names[i], names[j]) > 0) {
//////// temp = names[i];
//////// names[i] = names[j];
//////// names[j] = temp;
//////// temp = birthdays[i];
//////// birthdays[i] = birthdays[j];
//////// birthdays[j] = temp;
//////// }
//////// }
//////// }
////////
//////// // Show sorted names and birthdays
//////// printf("%s", sortedNamesTitle);
//////// for (i = 0; i < count; i++) {
//////// printf(nameTemplate, names[i], birthdays[i], i + 1, (void *)names[i], (void *)birthdays[i]);
//////// free(names[i]);
//////// free(birthdays[i]);
//////// }
//////// }
////////
//////// return 0;
////////}
////////
////////// Function to validate a date (YYYYMMDD)
////////bool isValidDate(const char* dateStr) {
//////// char* incorrectBirth = "Date format error! Please re-enter date.\n";
//////// int year;
//////// int month;
//////// int day;
////////
//////// if (getch(dateStr, "%4d%2d%2d", &year, &month, &day) != 3) {
//////// printf(incorrectBirth);
//////// // Unable to parse the input string
//////// return false;
//////// }
//////// // Year is out of the specified range
//////// if (year < 0000 || year > 9999) {
////////
//////// printf(incorrectBirth);
//////// return false;
//////// }
//////// // Month is out of range
//////// if (month < 1 || month > 12) {
//////// printf(incorrectBirth);
//////// return false;
//////// }
//////// // Day is out of range
//////// if (day < 1 || day > 31) {
//////// printf(incorrectBirth);
//////// return false;
//////// }
////////
//////// return true;
////////}
////////////////////////////////////////////////////////////////////////////////
////////NBv2.5
////////#include <stdio.h>
////////#include <stdlib.h>
////////#include <string.h>
////////#include <assert.h>
////////#include <stdbool.h>
////////#define maxLength 11
////////#define maxCount 5
////////typedef char* STRING;
////////bool isValidDate(const char* dateStr);
////////int main()
////////{
//////// // Variables
//////// int count = 0;
//////// STRING names[maxCount];
//////// STRING birthdays[maxCount];
//////// char nameInput[maxLength];
//////// char birthdayInput[9];
//////// STRING intro = "Records Entry and Sorting Program\nPlease input name and birthday (max: 5 entries).\n";
//////// STRING nameInputPrompt = "Name (First Last): ";
//////// STRING birthdayInputPrompt = "Birthday (YYYYMMDD): ";
//////// STRING nameTemplate = " %-10s %-8s Entry count: %2d malloc-address: %p -> %p\n";
//////// STRING sortedNamesTitle = "\nSorted Records:\n";
////////
//////// int length = 0;
//////// char c;
//////// int error = 0;
//////// int i;
//////// int j;
//////// STRING temp;
////////
//////// // Intro Template
//////// printf("%s", intro);
////////
//////// // Get names and birthdays
//////// while (count < maxCount && !error)
//////// {
//////// printf("%-10s", nameInputPrompt);
//////// length = 0;
//////// fflush(stdin);
//////// // Get name
//////// while ((c = getchar()) != '\n')
//////// {
//////// if (length < maxLength - 1)
//////// {
//////// nameInput[length++] = c;
//////// }
//////// }
////////
//////// nameInput[length] = '\0'; // Null-terminate the string
//////// if (strlen(nameInput) == 0) {
//////// printf("Incorrect name format.\n");
//////// error = 1;
//////// break;
//////// }
//////// else {
//////// names[count] = malloc(strlen(nameInput) + 1); // Allocate memory for the name
//////// assert(names[count] != NULL);
//////// strcpy(names[count], nameInput);
////////
//////// // Get birthday
//////// do {
//////// printf("%s", birthdayInputPrompt);
//////// scanf("%8s", birthdayInput);
//////// if (strlen(birthdayInput) == 0) {
//////// printf("Incorrect date format.\n");
//////// break;
//////// }
//////// } while (!isValidDate(birthdayInput));
////////
//////// birthdays[count] = malloc(9); // Allocate memory for the birthday (YYYYMMDD)
//////// assert(birthdays[count] != NULL);
//////// strcpy(birthdays[count], birthdayInput);
////////
//////// printf(nameTemplate, names[count], birthdays[count], count + 1, (void *)names[count], (void *)birthdays[count]);
//////// count++;
//////// }
//////// }
////////
//////// if (!error) {
//////// // Bubble sort
//////// for (i = 0; i < count - 1; i++) {
//////// for (j = i + 1; j < count; j++) {
//////// if (strcmp(names[i], names[j]) > 0) {
//////// temp = names[i];
//////// names[i] = names[j];
//////// names[j] = temp;
//////// temp = birthdays[i];
//////// birthdays[i] = birthdays[j];
//////// birthdays[j] = temp;
//////// }
//////// }
//////// }
////////
//////// // Show sorted names and birthdays
//////// printf("%s", sortedNamesTitle);
//////// for (i = 0; i < count; i++) {
//////// printf(nameTemplate, names[i], birthdays[i], i + 1, (void *)names[i], (void *)birthdays[i]);
//////// free(names[i]);
//////// free(birthdays[i]);
//////// }
//////// }
////////
//////// return 0;
////////}
////////
////////// Function to validate a date (YYYYMMDD)
////////bool isValidDate(const char* dateStr) {
//////// char* incorrectBirth = "Date format error! Please re-enter date.\n";
//////// int year;
//////// int month;
//////// int day;
////////
//////// if (sscanf(dateStr, "%4d%2d%2d", &year, &month, &day) != 3) {
//////// printf(incorrectBirth);
//////// // Unable to parse the input string
//////// return false;
//////// }
//////// // Year is out of the specified range
//////// if (year < 0000 || year > 9999) {
////////
//////// printf(incorrectBirth);
//////// return false;
//////// }
//////// // Month is out of range
//////// if (month < 1 || month > 12) {
//////// printf(incorrectBirth);
//////// return false;
//////// }
//////// // Day is out of range
//////// if (day < 1 || day > 31) {
//////// printf(incorrectBirth);
//////// return false;
//////// }
//////// // // Check for months ending in 30 days
//////// if ((month == 4 || month == 6 || month == 9 || month == 11) && day > 30) {
//////// printf(incorrectBirth);
//////// return false;
//////// }
////////
//////// // Check for February
//////// if (month == 2 && day > 28) {
//////// printf(incorrectBirth);
////////
//////// return false;
//////// }
////////
////////
//////// return true;
////////}
////////////////////////////////////////////////////////////////////////////////
///////////*************************************************************************/
///////////* */
///////////* Feature : Prompt the user to enter consecutively some five */
///////////* names of persons. Assign addresses per name, */
///////////* then display the names in alphabetical order, */
///////////* along with their addresses. */
///////////* */
///////////* Date : '23.10.02 */
///////////* */
///////////* Author : Maui Soliman, DTPH, Inc. */
///////////* */
///////////*************************************************************************/
//////#include <stdio.h>
//////#include <stdlib.h>
//////#include <string.h>
//////#include <assert.h>
//////#include <stdbool.h>
//////#define maxLength 11
//////#define maxCount 5
//////typedef char* STRING;
///////*************************************************************************/
///////* */
///////* Function name : isValidDate() */
///////* */
///////* Feature : This function checks if a given date string is */
///////* valid or not. It validates the year, month, */
///////* and day separately and also checks for case of */
///////* February. */
///////* */
///////* Argument : const char* dateStr */
///////* */
///////* */
///////* Return value : Boolean value */
///////* */
///////*************************************************************************/
//////bool isValidDate(const char* dateStr);
///////*************************************************************************/
///////* */
///////* Function name : main() */
///////* */
///////* Feature : This function is the entry point of the program. */
///////* It's responsible for getting names and birthdays */
///////* from the user,sorting them, and then displaying */
///////* the sorted records. */
///////* */
///////* Argument : const char* command */
///////* */
///////* */
///////* Return value : integer 0 */
///////* */
///////*************************************************************************/
//////int main()
//////{
////// // Variables
////// int count = 0;
////// STRING names[maxCount];
////// STRING birthdays[maxCount];
////// char nameInput[maxLength];
////// char birthdayInput[9];
////// STRING intro = "Records Entry and Sorting Program\nPlease input name and birthday (max: 5 entries).\n";
////// STRING nameInputPrompt = "Name (First Last): ";
////// STRING birthdayInputPrompt = "Birthday (YYYYMMDD): ";
////// STRING nameTemplate = " %-10s %-8s Entry count: %2d malloc-address: %p -> %p\n";
////// STRING sortedNamesTitle = "\nSorted Records:\n";
//////
////// int length = 0;
////// char c;
////// int error = 0;
////// int i;
////// int j;
////// STRING temp;
//////
////// // Intro Template
////// printf("%s", intro);
//////
////// // Get names and birthdays
////// while (count < maxCount && !error)
////// {
//////
////// printf("%-10s", nameInputPrompt);
////// length = 0;
////// fflush(stdin);
////// // Get name
////// while ((c = getchar()) != '\n')
////// {
//////
////// if (length < maxLength - 1)
////// {
////// nameInput[length++] = c;
////// }
////// if (strlen(names) == 0) {
////// printf("Incorrect name format.\n");
////// break;
////// }
////// }
//////
////// nameInput[length] = '\0';
////// // Null-terminate the string
////// if (!strcmp(nameInput, "0")) {
////// printf("name error");
////// continue;;
////// } else {
////// names[count] = malloc(strlen(nameInput) + 1); // Allocate memory for the name
////// assert(names[count] != NULL);
////// strcpy(names[count], nameInput);
//////
////// // Get birthday
////// do {
////// printf("%s", birthdayInputPrompt);
////// scanf("%8s", birthdayInput);
////// } while (!isValidDate(birthdayInput));
//////
////// birthdays[count] = malloc(9);
////// // Allocate memory for the birthday (YYYYMMDD)
////// assert(birthdays[count] != NULL);
////// strcpy(birthdays[count], birthdayInput);
//////
////// printf(nameTemplate, names[count], birthdays[count], count + 1, (void *)names[count], (void *)birthdays[count]);
////// count++;
////// }
////// }
//////
////// if (!error) {
////// // Bubble sort
////// for (i = 0; i < count - 1; i++) {
////// for (j = i + 1; j < count; j++) {
////// if (strcmp(names[i], names[j]) > 0) {
////// temp = names[i];
////// names[i] = names[j];
////// names[j] = temp;
////// temp = birthdays[i];
////// birthdays[i] = birthdays[j];
////// birthdays[j] = temp;
////// }
////// }
////// }
//////
////// // Show sorted names and birthdays
////// printf("%s", sortedNamesTitle);
////// for (i = 0; i < count; i++) {
////// printf(nameTemplate, names[i], birthdays[i], i + 1, (void *)names[i], (void *)birthdays[i]);
////// free(names[i]);
////// free(birthdays[i]);
////// }
////// }
//////
////// return 0;
//////}
//////
//////// Function to validate a date (YYYYMMDD)
//////bool isValidDate(const char* dateStr) {
////// char* incorrectBirth = "Date format error! Please re-enter date.\n";
////// int year;
////// int month;
////// int day;
//////
////// if (sscanf(dateStr, "%4d%2d%2d", &year, &month, &day) != 3) {
////// printf(incorrectBirth);
////// // Unable to parse the input string
//////
////// return false;
////// }
////// // Year is out of the specified range
////// if (year < 0000 || year > 9999) {
//////
////// printf(incorrectBirth);
////// return false;
////// }
//////
////// if (month < 1 || month > 12) {
////// printf(incorrectBirth);
////// // Month is out of range
////// return false;
////// }
//////
////// if (day < 1 || day > 31) {
////// printf(incorrectBirth);
////// // Day is out of range
////// return false;
////// }
//////
////// // Check for months ending in 30 days
////// if ((month == 4 || month == 6 || month == 9 || month == 11) && day > 30) {
////// printf(incorrectBirth);
////// return false;
////// }
//////
////// // Check for February
////// if (month == 2 && ((year % 4 != 0) || (year % 100 == 0 && year % 400 != 0)) && day > 28) {
////// printf(incorrectBirth);
//////
////// return false;
////// }
////// return true;
//////}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////NBv2.6
////
////#include <stdio.h>
////#include <stdlib.h>
////#include <string.h>
////#include <assert.h>
////
////#define MAXLENGTH 11
////#define MAXCOUNT 5
////
////typedef char* STRING;
////
////int isValidDate(const char *dateStr) {
//// int year, month, day;
//// if (sscanf(dateStr, "%4d%2d%2d", &year, &month, &day) != 3) {
//// // Unable to parse the input string
//// return 0; // false
//// }
////
//// if (year < 0 || year > 9999) {
//// // Year is out of range
//// return 0; // false
//// }
////
//// if (month < 1 || month > 12) {
//// // Month is out of range
//// return 0; // false
//// }
////
//// if (day < 1 || day > 31) {
//// // Day is out of range
//// return 0; // false
//// }
////
//// // Check for months ending in 30 days
//// if ((month == 4 || month == 6 || month == 9 || month == 11) && day > 30) {
//// return 0; // false
//// }
////
//// // Check for February
//// if (month == 2 && day > 28) {
//// return 0; // false
//// }
////
//// return 1; // true
////}
////
////// Function to compare names for sorting
////int compareNames(const void *a, const void *b) {
//// return strcmp(*(const STRING*)a, *(const STRING*)b);
////}
////
////// Function to sort names using bubble sort
////void bubbleSort(STRING names[], int count) {
//// int i, j;
//// for (i = 0; i < count - 1; i++) {
//// for (j = 0; j < count - i - 1; j++) {
//// if (strcmp(names[j], names[j + 1]) > 0) {
//// STRING temp = names[j];
//// names[j] = names[j + 1];
//// names[j + 1] = temp;
//// }
//// }
//// }
////}
////
////int main() {
//// // Variables
//// int count = 0;
//// STRING names[MAXCOUNT];
//// char nameInput[MAXLENGTH];
//// char birthInput[9];
//// STRING intro = "Records Entry and Sorting Program\nPlease input name and birthday (max: 5 entries).\n";
//// STRING nameInputPrompt = "Name (First Last): ";
//// STRING birthInputPrompt = "Birthday (YYYYMMDD): ";
//// STRING nameTemplate = "%-10s %-8s Entry count: %2d malloc-address: %p -> %p\n";
//// STRING sortedNamesTitle = "\nSorted records:\n";
//// int length = 0;
//// char c;
//// int error = 0;
//// int i;
//// STRING temp;
////
//// // Intro Template
//// printf("%s", intro);
////
//// // Get names and birthdays
//// while (count < MAXCOUNT && !error) {
//// printf("%s", nameInputPrompt);
//// length = 0;
////
//// // Get name
//// while ((c = getchar()) != '\n' && length < MAXLENGTH - 1) {
//// if (c != ' ') {
//// nameInput[length++] = c;
//// }
//// }
////
//// nameInput[length] = '\0'; // Null-terminate the string
////
//// if (!strcmp(nameInput, "0")) {
//// break;
//// } else {
//// printf("%s", birthInputPrompt);
//// if (fgets(birthInput, sizeof(birthInput), stdin) == NULL) {
//// error = 1; // Error reading input
//// break;
//// }
////
//// if (birthInput[0] == '\n') {
//// // Empty birthday input, terminate the program
//// break;
//// }
////
//// birthInput[strlen(birthInput) - 1] = '\0'; // Remove the newline character
////
//// if (!isValidDate(birthInput)) {
//// printf("Invalid date format.\n");
//// continue;
//// }
////
//// names[count] = malloc(strlen(nameInput) + 1); // Allocate memory for the name
//// assert(names[count] != NULL);
//// strcpy(names[count], nameInput);
//// printf(nameTemplate, names[count], birthInput, count + 1, (void *)names[count], (void *)&names[count]);
//// count++;
//// }
//// }
////
//// if (!error) {
//// // Sort names alphabetically using bubble sort
//// bubbleSort(names, count);
////
//// // Show sorted names and birthdays
//// printf("%s", sortedNamesTitle);
//// for (i = 0; i < count; i++) {
//// printf(nameTemplate, names[i], "", i + 1, (void *)names[i], (void *)&names[i]);
//// free(names[i]);
//// }
//// }
////
//// return 0;
////}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////NBv2.7
//#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <assert.h>
//#include <stdbool.h>
//#define maxLength 11
//#define maxCount 5
//typedef char* STRING;
//bool isValidDate(const char* dateStr);
//int main()
//{
// // Variables
// int count = 0;
// STRING names[maxCount];
// STRING birthdays[maxCount];
// char nameInput[maxLength];
// char birthdayInput[9];
// STRING intro = "Records Entry and Sorting Program\nPlease input name and birthday (max: 5 entries).\n";
// STRING nameInputPrompt = "Name (First Last): ";
// STRING birthdayInputPrompt = "Birthday (YYYYMMDD): ";
// STRING nameTemplate = " %-10s %-8s Entry count: %2d malloc-address: %p -> %p\n";
// STRING sortedNamesTitle = "\nSorted Records:\n";
//
// int length = 0;
// char c;
// static int error = 0;
// int i;
// int j;
// STRING temp;
//
// // Intro Template
// printf("%s", intro);
//
// // Get names and birthdays
// while (count < maxCount && !error)
// {
// printf("%-10s", nameInputPrompt);
// length = 0;
// fflush(stdin);
// // Get name
// while ((c = getchar()) != '\n')
// {
// if (length < maxLength - 1)
// {
// nameInput[length++] = c;
// }
// }
// nameInput[length] = '\0'; // Null-terminate the string
//
// if (strlen(nameInput) == 0) {
// printf("Incorrect name format.\n");
// error = 1;
// break;
// }
//
// else if (!strcmp(nameInput, "0")) {
// printf("name error");
// error = 1;
// break;
// } else {
// printf("%s", birthdayInputPrompt);
// if (fgets(birthdayInput, sizeof(birthdayInput), stdin) == NULL) {
// error = 1; // Error reading input
// break;
// }
//
// if (birthdayInput[0] == '\n') {
// // Empty birthday input, terminate the program
// break;
// }
//
// birthdayInput[strlen(birthdayInput) - 1] = '\0'; // Remove the newline character
//
// if (!isValidDate(birthdayInput)) {
// printf("Invalid date format.\n");
// continue;
// }
//
// names[count] = malloc(strlen(nameInput) + 1); // Allocate memory for the name
// assert(names[count] != NULL);
// strcpy(names[count], nameInput);
// printf(nameTemplate, names[count], birthdayInput, count + 1, (void *)names[count], (void *)&names[count]);
// count++;
// }
// }
//
// if (!error) {
// // Bubble sort
// for (i = 0; i < count - 1; i++) {
// for (j = i + 1; j < count; j++) {
// if (strcmp(names[i], names[j]) > 0) {
// temp = names[i];
// names[i] = names[j];
// names[j] = temp;
// temp = birthdays[i];
// birthdays[i] = birthdays[j];
// birthdays[j] = temp;
// }
// }
// }
//
// // Show sorted names and birthdays
// printf("%s", sortedNamesTitle);
// for (i = 0; i < count; i++) {
// printf(nameTemplate, names[i], birthdays[i], i + 1, (void *)names[i], (void *)birthdays[i]);
// free(names[i]);
// free(birthdays[i]);
// }
// }
//
// return 0;
//}
//
//// Function to validate a date (YYYYMMDD)
//bool isValidDate(const char* dateStr) {
// char* incorrectBirth = "Date format error! Please re-enter date.\n";
// int year;
// int month;
// int day;
//
// if (getch(dateStr, "%4d%2d%2d", &year, &month, &day) != 3) {
// printf(incorrectBirth);
// // Unable to parse the input string
// return false;
// }
// // Year is out of the specified range
// if (year < 0000 || year > 9999) {
//
// printf(incorrectBirth);
// return false;
// }
// // Month is out of range
// if (month < 1 || month > 12) {
// printf(incorrectBirth);
// return false;
// }
// // Day is out of range
// if (day < 1 || day > 31) {
// printf(incorrectBirth);
// return false;
// }
//
// return true;
//}
//
}