收到错误"预计标识符或'('前'{'用C令牌 [英] Getting the error "expected identifier or '(' before '{' token in C

查看:297
本文介绍了收到错误"预计标识符或'('前'{'用C令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何帮助将是巨大的!

#include <stdio.h>
#define pi 3.14159



int main()
{
  float r;
  char PI;

/*Program for circumference. */

    printf(" This is a program that will calculate circumference.\n");
    printf("Please put in your radius.\n");

    scanf("%f", &r);
    printf("Please input PI\n");
    PI = getchar();
 }

   {
    if {(char != PI || 3.14);
    printf("Incorect value\n");
}

    else {
    printf("Thank you, the circumference is now.\n");
    printf("%f", (r) * pi *2);
}


return 0;

}

我想弄清楚这个错误,我肯定,四处搜寻,但没有真正弹起我的具体问题。如果有帮助,这是正确的if语句开始之前。也许我会用太多了{?

I'm trying to figure out this error, I have definitely searched around, but nothing really has popped up with my specific problem. If it helps, it is right before the "if" statement begins. Might I be using one too many '{'?

推荐答案

我已经指出了comments.Make错误它采用帽子的习惯的#define 宏,不是为variables.And最后,为您的病情如果如果(PI!= PI)卸下摆臂的 {之间的如果和,和也是;

I have pointed out the errors with comments.Make it a habit to use caps for the #define macro, not for the variables.And finally, the condition for your if should be if(PI!=pi).Remove the { between if and the (, and also the ; after the )

#include <stdio.h>
#define pi 3.14159



int main()
{
  float r;
  char PI;

/*Program for circumference. */

    printf(" This is a program that will calculate circumference.\n");
    printf("Please put in your radius.\n");

    scanf("%f", &r);
    printf("Please input PI\n");
    PI = getchar();
 } //This is the source of error as `main()` ends after this `}'

   {
    if(PI!=pi)  //You have used a `;` after if's condition & an extra '{' before it
    printf("Incorect value\n");
}

    else {
    printf("Thank you, the circumference is now.\n");
    printf("%f", (r) * pi *2);
}


return 0;

}

这篇关于收到错误&QUOT;预计标识符或'('前'{'用C令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆