64 lines
1.5 KiB
C
64 lines
1.5 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "village.h"
|
|
|
|
int main()
|
|
{
|
|
struct villager *island = NULL;
|
|
unsigned int population = 0;
|
|
|
|
printf("--- Welcome to the Animal Crossing Management System ---\n");
|
|
|
|
struct villager v1 = {
|
|
"Tom Nook",
|
|
45,
|
|
SELLER,
|
|
"I'll need those Bells, yes yes!",
|
|
};
|
|
struct villager v2 = {
|
|
"K.K. Slider",
|
|
25,
|
|
MUSICIAN,
|
|
"The music wants to be free, man. Rock on.",
|
|
}; // Longest
|
|
struct villager v3 = {
|
|
"Blathers",
|
|
40,
|
|
WORKER,
|
|
"Hoo!",
|
|
};
|
|
|
|
add_villager(&island, &population, v1);
|
|
add_villager(&island, &population, v2);
|
|
add_villager(&island, &population, v3);
|
|
|
|
printf("Current Island Population: %u villagers.\n", population);
|
|
|
|
printf("\n[Step 1] Exporting quotes to 'bulletin_board.txt'...\n");
|
|
int list_status = list_quotes("bulletin_board.txt", island, population);
|
|
if (list_status != 0)
|
|
{
|
|
printf("Error: Could not write to file (Status %d)\n", list_status);
|
|
}
|
|
|
|
printf("[Step 2] Searching for the second longest quote in the file...\n");
|
|
char *second = second_longest_quote("bulletin_board.txt");
|
|
|
|
if (second)
|
|
{
|
|
printf("SUCCESS! The second longest quote is: \"%s\"\n", second);
|
|
free(second);
|
|
}
|
|
else
|
|
{
|
|
printf("FAILURE: No second longest quote found (File too short or "
|
|
"NULL).\n");
|
|
}
|
|
|
|
clear_village(&island, &population);
|
|
printf("\nIsland closed for maintenance. See you tomorrow!\n");
|
|
|
|
return 0;
|
|
}
|