gpt4 book ai didi

c - 错误 : expected an identifier

转载 作者:太空宇宙 更新时间:2023-11-04 05:28:37 26 4
gpt4 key购买 nike

我在使用 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;
}`

最佳答案

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<0");作为 while 条件,这里 "p<0"是一个字符串,您可能想将其更改为 p<0 .

关于c - 错误 : expected an identifier,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14330390/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com