The source code seems to be C and not C++ except for true and false.
But the two boolean expressions are also used rather like in C, because something like this
should not happen in C++:
int z = false;
The compiler does not find several declarations:
vacc.c(30): warning C4013: "readFile" undefined; assumption: external with return type int
vacc.c(39): error C2065: "vacc": undeclared identifier
vacc.c(39): error C2109: index requires an array or pointer type
vacc.c(39): warning C4477: "printf": The format string "%s" requires an argument of type "char *", but the variadic argument "1" has type "int".
vacc.c(39): warning C4473: "printf": not enough arguments passed for format string
vacc.c(39): note: placeholders and their parameters expect 5 variadic arguments, but 1 variadic argument was provided.
vacc.c(39): note: The missing variadic argument "2" is required for the string "%-10s".
vacc.c(47): error C2065: "count": undeclared identifier
This can be easily solved by moving it to the beginning of the source code under the declaration of the struct vaccine.
struct vaccine vacc[30];
int count = 0;
FILE *f;
int writefile();
int readFile();
void CODEChecker(int x, int count) {};
But there are still some questions that the author should think about.
Should it be C or C++?
Declaration or use of true and false
vacc.c(66): warning C4013: "gets" undefined; assumption: external with return type int
vacc.c(82): error C2065: "false": undeclared identifier
vacc.c(89): error C2065: "true": undeclared identifier
vacc.c(99): error C2065: "false": undeclared identifier
vacc.c(116): warning C4013: "checkCODE" undefined; assumption: external with return type int
vacc.c(127): error C2065: "id": undeclared identifier
vacc.c(127): warning C4047: "function": number of dereferences for "const char *" and "int" different
vacc.c(127): warning C4024: "strcmp": different types for formal and passed parameter 1
*the compiler messages were processed with a translator and are not original.
//edit1:
The gets() function has been completely removed from C since version C11 due to problems. Instead, a safer variant called gets_s() should be used, which uses the maximum number of characters to be read as an additional parameter:
char *gets_s( char *str, rsize_t n );
// edit2:
count = readFile();
gets_s(vacc[count].code, sizeof(vacc[0].code));
To prevent count from becoming negative, you could check at the beginning if the file exists and create it without data if necessary.
If the file does not exist count has the value -1. Accessing the array vacc with -1 leads to a crash. It would be better to keep the name of the file in a variable:
char* const vacc_filename = "Vaccine inventory.txt";
int main()
{
if (!file_exists(vacc_filename)) {
count = 0;
writefile(vacc_filename);
}
count = readFile(vacc_filename);
...