0
I am only doing this program to train, and I want to print a message saying "invalid object" if what I type is different from the solids that will be declared in the variables, but with a loop while
to return so that I can type the solid again. But if I print the invalid object message within the function do
it will print the first time even if I type a valid object.
void main()
{
system("cls");
setlocale(LC_ALL, "");
int comp;
float raio, alt;
char sld[19];
char cil[9] = "cilindro";
printf("\t\t ========== Calculadora de Volume ==========");
do
{
printf("\n\n Digite o sólido: ");
fgets(sld, 61, stdin);
fflush(stdin);
comp = strcmp(sld, cil);
}
while (comp != 0);
can place the condition within an if:
if (comp != 0) printf("objeto inválido");
plain as that– Ricardo Pontual