Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int set_hp_from_file(FILE* fp, char* path, Member *m){
- int c;
- int hp_beg = 0;
- int hp_end = 0;
- int file_index = 0;
- rewind(fp);
- while((c = fgetc(fp)) != EOF){
- file_index++;
- if(c == '\n'){
- if(hp_beg){
- hp_end = file_index - 1;
- break;
- }else{
- hp_beg = file_index;
- }
- }
- }
- int w;
- int t;
- int hp_to_char_index = 0;
- char* p = malloc(5);
- int d;
- rewind(fp);
- for(w = hp_beg; w < hp_end ; w++){
- fseek(fp, w, SEEK_SET);
- d = fgetc(fp);
- p[hp_to_char_index] = d;
- hp_to_char_index++;
- }
- m->hp = atoi(p);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement