refactor: reorganize directory structure

This commit is contained in:
Kiana Sheibani 2025-09-04 22:01:00 -04:00
parent 433a4f2c0d
commit d4913ac8df
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
5 changed files with 5 additions and 5 deletions

View file

@ -0,0 +1,39 @@
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main() {
FILE *logfile; // Pointer to file structure
char message[100];
time_t current_time;
// Open file for appending ("a" mode)
// "w" would overwrite, "r" would read
logfile = fopen("owltech.log", "a");
// Always check if file opened successfully
if (logfile == NULL) {
printf("Error: Could not open log file\n");
return 1; // Return non-zero to indicate error
}
printf("Enter log message: ");
fgets(message, sizeof(message), stdin);
// Get current time
time(&current_time);
// Write to file with timestamp
// fprintf works like printf but writes to a file
fprintf(logfile, "[%s] %s", ctime(&current_time), message);
// Always close files when done
fclose(logfile);
printf("Log entry saved successfully!\n");
// Display the log file contents
printf("\n--- Current Log Contents ---\n");
system("cat owltech.log");
return 0;
}