Untitled
unknown
plain_text
3 years ago
2.3 kB
3
Indexable
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 500 #define MAX_NAME 30 #define MAX_FIREFIGHTERS 9 #define MAX_OPERATIONS 100 typedef struct { char name[MAX_NAME]; int n_operations; int minutes_op[MAX_OPERATIONS]; } FireFighter; typedef struct { char team_id; int n_firefighters; FireFighter firefighters[MAX_FIREFIGHTERS]; } Team; int myAtoi(char input[MAX]) { int result = 0; int i = 0; //23\0 -> 50 y un 51 //0 -> 48 while(input[i] != '\0') { //printf("\nValor de %c en ascii: %d\n", input[i], input[i]); result = result * 10 + (input[i] - '0'); //printf("\n%d\n", result); i++; } return result; } /* F/2/jack willis/anne home/B/1/lucas tee warlow/D/1/jhonny crash. */ int main() { Team team[9]; char input[500]; char aux[50]; int i = 0, j = 0, countTeam = 0, all = 0; printf("Enter information: "); fgets(input, MAX, stdin); printf("Longitud sin quitan: %d", (int)strlen(input)); input[strlen(input)-1] = '\0'; printf("\nLongitud quitando: %d", (int)strlen(input)); printf("\n%s\n", input); while(input[i] != '\0') { j = 0; while(input[i] != '/') { aux[j] = input[i]; i++; j++; } aux[j] = '\0'; team[countTeam].team_id = aux[0]; i++; j = 0; while(input[i] != '/') { aux[j] = input[i]; i++; j++; } aux[j] = '\0'; team[countTeam].n_firefighters = myAtoi(aux); printf("Num: %d\n", team[countTeam].n_firefighters); j = 0; i++; printf("AAAAANum: %d\n", team[countTeam].n_firefighters); printf("hola"); while(all != 5) { j = 0; printf("aqui"); while(input[i] != '/' || input[i] != '.') { team[countTeam].firefighters[all].name[j] = input[i]; i++; j++; } team[countTeam].firefighters[all].name[j] = '\0'; i++; printf("Bomb: %s", team[countTeam].firefighters[all].name); all++; } printf("%c\n", team[countTeam].team_id); i++; } return 0; }
Editor is loading...