storage.txt is now created at runtime rather than being assumed to be present and empty. recall() now removes storage.txt at completion. main() now includes a check to see whether storage.txt already exists, sends an error message, and exits with code 1 if storage.txt is already present.

This commit is contained in:
Reina Harrington-Affine 2025-09-02 21:02:47 +00:00
parent 5ec722b2ca
commit 481f76699e

View file

@ -1,4 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void store();
void enumerate();
@ -7,6 +9,11 @@ int longest = 0;
int posLongest = 0;
int main(){
if((access("storage.txt",F_OK)) == 0){
printf("Error: storage file already exists.");
return 1;
EXIT_FAILURE;
}
store();
enumerate();
recall();
@ -72,4 +79,5 @@ void recall (){
}
}
fclose (fp);
remove("storage.txt");
}