【问题标题】:error: expected an identifier错误:需要一个标识符
【发布时间】:2013-01-15 02:49:23
【问题描述】:

我在使用 Visual Studio 时遇到以下错误:

41 IntelliSense:需要一个标识符

我不知道这是在说什么,任何帮助将不胜感激! :D

这是程序:

#include <stdio.h>
#include <math.h>

int
main(void)
{
         long long d;
     long long p;

     //Ask for numbers of days as long as input is not between 28 and 31

    do
    {
    printf("How may days are in your month?\n");
    d = GetInt();
    }
    while (d<28 || d>31);


    //Ask for numbers of pennies for day 1 as long as input is negative



    printf("How many pennies do you have");
    do
    {
        p = GetInt();
    }
    while ("p<0");


    //Sum up the pennies, pennies = (pennies*2)*2..*2

    int 1;
    for (i=0; i<= d-1; i++);
        {

            p=p*pow(2,i);
        }       
    printf("%lld\n", p);
    return 0;
}`

【问题讨论】:

    标签: c random identifier


    【解决方案1】:
    int 1;
    for (i=0; i<= d-1; i++);
    

    这里有int 1;,所以编译器正在寻找一个变量名,例如int x = 1; 现在是 for 循环,从末尾删除 ;

    main 中,前两行是

    long long d;
    long long p;
    

    这里long 是一个类型,所以将这些行改为

    long d;
    long p;
    

    在文件末尾我看到}',这里删除' 字符

    另外,我可以看到你有while ("p&lt;0");作为while条件,这里"p&lt;0"是一个字符串,你可能想把它改成p&lt;0

    【讨论】:

      【解决方案2】:

      你可能也想替换

      while ("p<0"); 
      

      while(p<0);
      

      (不带引号)。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-02-17
        • 1970-01-01
        • 1970-01-01
        • 2023-01-01
        • 1970-01-01
        • 2023-03-31
        相关资源
        最近更新 更多