如果在C中,则为其他语法

时间:2014-01-12 11:01:43

标签: c syntax

不好意思,但我需要一双新的眼睛。

case '2':
    printf("\n>>> Desligar equipamento <<<");
    do {
        printf("\nNumero? ");scanf("%d",&nr);
    }
    while (nr<1 || nr>99);

    if (retirar(nr, f_equipamento_uso, f_categoria)){
       registarHora(n, 0, equipamento, data); //moved from the else
       unblanker(nr, f_equipamento_uso, f_categoria);               
       //Imprimir Eq Disponiveis para verificar função abaixo
       printf("\nRemover dos Equipamentos Disponiveis? S/N");
       scanf("%c", &sn);
       getch();

       if (sn == 'S' || sn == 's') {
           printf("should remove from dsp"); 
           getch(); 
           //retirar(nr, f_equipamento_disp, f_categoria);
       }
       else {
         //This is the **bold else**
       }
    else {
       printf("Equipamento nao existe.");
       getch();    
    }                   
  } 
  break;

我在那里有两个。 删除粗体的其他我可以编译,但不能正常工作,因为它“删除”最后一个if。 如果我不删除,我有语法错误

1 个答案:

答案 0 :(得分:2)

您应该在

之前插入}
else {
       printf("Equipamento nao existe.");
       getch();    
    }

然后您的代码将看起来像这样的结构:

case constant-expression:

do
{
} while(expression);

if (expression)
{

    if (expression)
    {
    }
    else
    {
    }

}
else
{
}

}

break;