// // Created by Kyle Stevenson on 21/01/2025. // #include "memory_info.h" #include "prime_sieves.h" #include #include #include // For getcwd() #include // For PATH_MAX #include // For snprintf() int main() { // Step 1: Calculate available bits const size_t availableBits = getAvailableBits(2); if (availableBits > 0) { printf("You can allocate ~%zu bits.\n", availableBits); } // Step 2: Get absolute path for `primes.db` char dbFilePath[PATH_MAX]; if (getcwd(dbFilePath, sizeof(dbFilePath)) != NULL) { if (snprintf(dbFilePath, sizeof(dbFilePath), "%s/primes.db", dbFilePath) >= sizeof(dbFilePath)) { fprintf(stderr, "Path too long for database file.\n"); return 1; } printf("Database file will be created at: %s\n", dbFilePath); } else { fprintf(stderr, "Failed to get current working directory.\n"); return 1; } // Step 3: Run the Sieve and save primes to SQLite sieveOfEratosthenes(availableBits, dbFilePath); return 0; }