|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
这是在VS Code的编译,主要问题就是extern关键字出现错误
//*************************************************************************
PS C:\Users\57116\Desktop\study_world\C_world\CPP program\vs_code\12.5> gcc .\parta.c .\partb.c -o aa
.\partb.c:3:8: error: expected ';' before 'int'
exetern int count;
^~~~
;
PS C:\Users\57116\Desktop\study_world\C_world\CPP program\vs_code\12.5>
***************************************************************************//
//parta.c
#include "stdio.h"
void report_count();
void accumulate(int k);
int count = 0;
int main(void)
{
int value;
register int i;
printf("Enter a positive integer (0 to quit): ");
while (scanf("%d", &value) == 1 && value > 0)
{
++count;
for (i = value; i >= 0; i++)
accumulate(i);
printf("Enter a positive integer (0 to quit)");
}
report_count();
return 0;
}
void repor_count()
{
printf("Loop executed %d times\n", count);
}
//partb.c
#include "stdio.h"
exetern int count;
static int total = 0;
void accumulate(int k);
void accumulate(int k)
{
static int subtotal = 0;
if (k <= 0)
{
printf("loop cycle: %d\n", count);
printf("subtotal: %d; total: %d\n", subtotal, total);
subtotal = 0;
}
else
{
subtotal += k;
total += k;
}
}
PS C:\Users\57116\Desktop\study_world\C_world\CPP program\vs_code\12.5> gcc .\parta.c .\partb.c -o aa
.\partb.c:3:8: error: expected ';' before 'int'
exetern int count;
^~~~
;
PS C:\Users\57116\Desktop\study_world\C_world\CPP program\vs_code\12.5>
|
|