TOPIC

Runtime error

Ferdinando Galera asked 1 year ago

Alguém poderia me dizer o que ah de errado no meu código? aparece o erro de Runtime error, mesmo ele funcionando fora do site

include

int main() { float A, B; double C, D; char STR[10];

scanf("%f%f",&A,&B);
scanf("%lf%lf",&C,&D); 

printf("A = %f, B = %f\nC = %lf, D = %lf\n",A, B, C, D); 
printf("A = %.1f, B = %.1f\nC = %.1lf, D = %.1lf\n",A, B, C, D); 
printf("A = %.2f, B = %.2f\nC = %.2lf, D = %.2lf\n",A, B, C, D); 
printf("A = %.3f, B = %.3f\nC = %.3lf, D = %.3lf\n",A, B, C, D); 
sprintf(STR,"%.3E",A); STR[9] = '\0'; 
printf("A = %s,",STR);
sprintf(STR,"%.3E",B); STR[9] = '\0'; 
printf(" B = %s\n",STR); 
sprintf(STR,"%.3lE",C); STR[9] = '\0'; 
printf("C = %s,",STR); 
sprintf(STR,"%.3lE",D); STR[9] = '\0'; 
printf(" D = %s\n",STR);
printf("A = %d, B = %d\nC = %d, D = %d\n",(int)A,(int)B,(int)C,(int)D); 

return 0;

}

Remember not post solutions. Your post may be reviewed by our moderators.

  • feodorv replied 1 year ago

    Too small buffer size for STR. Why did you use it? Why not print all values just on screen?