0
This is what I need to do
Create an algorithm where you calculate through various temperature inputs the percentage outside the variation stipulated as maximum and minimum having as out of +-3 values from stipulated temperature values, out of that is outside the target values, and should present the corresponding percentage to what is outside.
how far I’ve come :
#include<stdio.h>
#include<string.h>
int main(void){
float entrance;
char Str[50];
FILE *arq;
char Linha[100];
char *result;
int i;
// Abre um arquivo TEXTO para LEITURA
arq = fopen("arq.txt", "rt");
if (arq == NULL){
printf("Problemas na abertura do arquivo\n");
return;
}
i = 1;
while (!feof(arq)){
result = fgets(Linha, 100, arq);
if (result)
i++;
}
fclose(arq);
puts("\n\t ");
puts("\t - - imported file - - ");
puts(" press Enter... ");
getchar();
puts("\t* SELECIONE UMA OPCAO DESEJADA: *");
puts("\t* *");
puts("\t* 1 3 graus celcius *");
puts("\t* 2 -3 graus celcius *");
puts("\t* 3 -5 graus celcius *");
puts("\t* 4 -8 graus celcius *");
puts("\t* 5 -12 graus celcius *");
puts("\t* 6 -15 graus celcius *");
puts("\t* 7 -18 graus celcius *");
scanf("%f",&entrance);
/*
--FAZER A MEDIA DOS VALORES E MOSTRAR A PORCENTAGEM QUE
FICA FORA DE ACORDO COM O VALOR DE 'ENTRANCE'
--APRESENTAR RESULTADO EM TELA E RETORNAR EM ARQUIVO .TXT
*/
getchar();
return 0;
}
I don’t know exactly how to do this part
--AVERAGE THE VALUES AND SHOW THE PERCENTAGE THAT IS OUT ACCORDING TO THE ENTRANCE VALUE'
--DISPLAY RESULT ON SCREEN AND RETURN IN FILE . TXT
Line (52) p = realloc( p, i * sizeof(double)); error for me ! Invalid conversion from VOID to DOUBLE
– AGenaro
@Agenaro: The following edition:
p = (double*) realloc( p, i * sizeof(double));
– Lacobus