How to read data from a .txt file

0
Hello, I am developing a queue of banks in C. How can I read entries in a file and thus assign values to some specific variable in my program?

Example: I have a int qtd_boxes variable in main. I need to assign this variable a value read in a text file that will be informed by the user. (The formatting of the file does not change.)

Example input:

qtde de caixas = 9
delta t = 3
disciplina de escalonamento = {8,6,4,3,2}
//Aqui eu preciso armazenar um char "tipo da conta", um int "numero da 
conta" e outro int "numero de operações"
Comum - conta 997002 - 6 operacao(oes)
Prata - conta 520699 - 11 operacao(oes)
Prata - conta 932923 - 2 operacao(oes)

Current Code:

int qtd_caixas, delta_t;
int e1, e2, e3, e4, e5;
char tipo_cliente[10];
int num_conta;
int operacoes;

FILE *arq = fopen("entrada-X.txt", "r+");
if(arq == NULL){
    exit(1);
}
    
asked by anonymous 18.11.2018 / 15:41

0 answers