Advertisement
Gabriel_Rofl

Untitled

Nov 17th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.13 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "got.h"
  4.  
  5. int main () {
  6.  
  7.     FILE *personagens;
  8.  
  9.     char nome[10000];
  10.     char house[10000];
  11.     char virgula;
  12.     int agility, strength, intelligence, health;
  13.  
  14.     personagens = fopen("personagens.txt", "r");
  15.  
  16.     if(personagens == NULL){
  17.         exit(-1);
  18.     }
  19.  
  20.     lista* l = aloca_lista();
  21.  
  22. while(fscanf(personagens,"%d, %d, %d, %d", &agility, &strength, &intelligence, &health) != EOF){  
  23.  
  24.     fscanf(personagens, "%[^',']s", nome);
  25.  
  26.     fgetc(personagens);
  27.  
  28.     fscanf(personagens, "%[^',']s", house);
  29.  
  30.     fgetc(personagens);
  31.  
  32.     fscanf(personagens,"%d, %d, %d, %d", &agility, &strength, &intelligence, &health);
  33.  
  34.     Character* character = character_create(nome, house, agility, strength, intelligence, health);
  35.  
  36.     printf("NOME:%s\nCASA:%s\nAgility:%d\nStrength:%d\nIntelligence:%d\nHealth:%d\n", character->name, character->house, character->agility, character->strength, character->intelligence, character->health);
  37.  
  38.     printf("\n\n");
  39.  
  40.     inserir_character(character, l);
  41. }
  42.  
  43.     fclose(personagens);
  44.  
  45.  
  46.  
  47.  
  48.    
  49.  
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement