All pastes #269572 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-12-06 17:41 UTC
rendered paste body
#include <stdio.h>
#include <stdlib.h>
#define SAVE_DELIMETER

typedef struct {
int hp, level, str, exp, maxhp;
} stats;

void loadSavedGame(char *name, stats *player) {
        FILE *game;
        char *filename;

        filename = malloc(10 + sizeof(name));
        sprintf(filename, "savedgames/%s",name);
        filename = "test.file";
        if((game = fopen(filename,"r")) == NULL) {
                printf("You don't have a saved game under that name.\n");
                exit(1); // will replace this later, it's not important right now
                }
        fscanf(game,"%d %d ",&player->level,&player->exp,&player->str,
                             &player->hp,&player->maxhp);
        fclose (game);
        free (filename);
        player->hp = 119;
        printf("worked %i\n",player->hp);
}

main() {
        char boo[10] = "oorza";
        stats playeer, *player;
        player = &playeer;
        loadSavedGame(boo, player);
        printf("%i %i\n",player->hp,player->level);
}