Commit 6d171542 by grlabu

Delete loader.c

parent 88f44526
Showing with 0 additions and 36 deletions
#include "Header.h"
int SaveGame(char *file, Player *p, int enemiesDefeated)
{
FILE *fh;
fh = fopen(file, "w");
if (fh == NULL)
{
fprintf(stderr, "Error opening save file!\n");
return 1;
}
fprintf(fh, "%d %d %d\n%d", p->health, p->attack, p->potionCount,
enemiesDefeated);
fclose(fh);
return 0;
}
void LoadGame(char *file, Player *p, int *enemies)
{
FILE *fh;
fh = fopen(file, "r");
if (fh == NULL)
{
fprintf(stderr, "Failed to open file %s\n", file);
exit(1);
}
fscanf(fh, "%d %d %d", &p->health, &p->attack, &p->potionCount);
fscanf(fh, "%d", enemies);
fclose(fh);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment