c/c++语言开发共享获取错误“预期标识符或’(’在C之前的”’标记

任何帮助都会很棒!

#include  #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 PIn"); PI = getchar(); } { if {(char != PI || 3.14); printf("Incorect valuen"); } else { printf("Thank you, the circumference is now.n"); printf("%f", (r) * pi *2); } return 0; } 

我正试图弄清楚这个错误,我肯定已经四处寻找,但没有真正突然出现我的具体问题。 如果它有帮助,它就在“if”语句开始之前。 我可能会使用太多'{‘?

    我已经用注释指出了错误。习惯为#define宏使用大写,而不是变量。最后,你的if的条件应该是if(PI!=pi)删除{之间if( ,以及之后)

     #include  #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 PIn"); 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 valuen"); } else { printf("Thank you, the circumference is now.n"); printf("%f", (r) * pi *2); } return 0; } 

    您正在以第一个}字符终止主要function。 你有一个开放和闭合括号的不均匀匹配,这是导致问题。 你的if语句也有问题。 这个

     if {(char != PI || 3.14); 

    应该读作

     if (char != PI || 3.14) 

    或者更具体地说,整个if-else应该是

     if (char != PI || 3.14) { printf("Incorect valuen"); } else { printf("Thank you, the circumference is now.n"); printf("%f", (r) * pi *2); } 

      以上就是c/c++开发分享获取错误“预期标识符或’(’在C之前的”’标记相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/c-cdevelopment/549539.html

      (0)
      上一篇 2021年1月14日
      下一篇 2021年1月14日

      精彩推荐