This commit is contained in:
2026-02-26 15:05:36 +01:00
commit 88b0c96605
10 changed files with 83 additions and 0 deletions
View File
+63
View File
@@ -0,0 +1,63 @@
#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;
}
View File
View File