c - 我得到 "greedy.c:17:1: error: expected identifier or ' (' {"有人可以帮忙吗?它指的是 int main(void) 之后的行

标签 c identifier cs50

/**************************************************
 * Greedy.c
 *
 * CS50x pset1
 * Daniel Riley
 *
 * A program that determines the minimum amount of
 * coins used for change owed
 *
 *
 **************************************************/
 #include <stdio.h>
 #include <cs50.h>
 #include <math.h>

 int main (void);
 {

 float change;
 int cents = round (change * 100);
 int coins = 0;

 do
     {
     printf("How much change is required? ");
     change = GetFloat();
     }
 while(change < 0);

 do
     {
     cents -= 25;
     coins ++;
     }
 while(cents >= 25);

 do
     {
     cents -= 10;
     coins ++;
     }
 while(cents >= 10);

 do
     {
     cents -= 5;
     coins ++;
     }
 while(cents >= 5);

 do
     {
     cents -= 1;
     coins ++;
     }
 while(cents >= 1);

 printf("%d\n", coins);
 return 0;
 }

编译时出现错误预期标识符“(”,请帮忙。它是第 17 行,即 int main(void) 之后的行。据我所知,我已正确地将所有函数括起来。程序必须询问用户找零并确定找零时使用的最少硬币数量

最佳答案

这不是int main(void)之后的行,而是int main(void);之后的行。换句话说,删除第 16 行中的 ;

关于c - 我得到 "greedy.c:17:1: error: expected identifier or ' (' {"有人可以帮忙吗?它指的是 int main(void) 之后的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14561791/

相关文章:

c - 核心被抛弃?

c - 当增加指针时,分配给指针的内存大小会发生变化

python - SQL炼金术 : random Unique integer?

ios - 使用未解析的标识符 - 使用 Swift Project 2 进行应用程序开发

javascript - 从 div 元素获取 id 并将其显示为警报

C - 在 Mac OSX Lion 上编译时架构 x86_64 的 undefined symbol

c - 在返回类型为void的函数中,语句return;的含义是什么?

c - 为结构数组中的结构成员分配内存后写入无效

c - 为什么这段代码会删除前 3 个字符?

c - 为什么我在 C 语言中收到警告 'Segmentation fault, core dumped'