#include <stdio.h>
#include <string.h>
int goto_error_handling() {
int result = 0;
FILE* f = fopen("logfile.txt", "w+");
if (!f) {
return -1;
}
if (fputs("logfile line 1", f) == EOF) {
result = -2;
goto out;
}
// your code...
// Releasing resources
out:
if (fclose(f) == EOF) {
result = -3;
}
return result;
}
int main()
{
printf("%d\n", goto_error_handling());
return 0;
}
/*
run:
0
*/