C语言 错误:需要一个标识符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14330390/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 05:02:27  来源:igfitidea点击:

error: expected an identifier

crandomidentifier

提问by Caleb Lawrence

I am getting the following error using Visual Studio:

使用 Visual Studio 时出现以下错误:

41 IntelliSense: expected an identifier

41 智能感知:需要一个标识符

I have no idea what this is trying to say and any help would be appreciated! :D

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

Here is the program:

这是程序:

#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;
}`

回答by Robin Chander

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

Here you have int 1;so the compiler is looking for a variable name such as int x = 1;Now the for loop, remove that ;from the end

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

inside the mainthe first two lines you have are

main您拥有的前两行内

long long d;
long long p;

Here longis a type, so change those lines to

long是一种类型,因此将这些行更改为

long d;
long p;

At the end of you file i see }', here remove the 'character

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

In addition, I can see you have while ("p<0");as the while condition, here "p<0"is a string, you might want to change it to p<0.

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

回答by PhoenixWing156

You also probably want to replace

您可能还想更换

while ("p<0"); 

with

while(p<0);

(without the quotes).

(没有引号)。