错误:预期';' 在数字不变之前

0 c compiler-errors

我是编程新手,我正在努力学习,所以我想写点什么.但是有这样的错误说:期待';' 数字不变之前.有谁知道为什么?谢谢.正如我所说,我是编程新手所以不要对我极其简单的代码感到惊讶:D

struct Country{
    char name[50];
    char capital[50];
    char statehead[50];
    int pop;
double area;
};

int main(){

    struct Country stat1;
    stat1.area = 78 866.2;
    stat1.pop = 10 560 000;
    strcpy( stat1.name, "Ceska republika");
    strcpy( stat1.capital, "Praha");
    strcpy( stat1.statehead, "MilosZeman");

    printf("%d", stat1.area);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

Her*_*ers 5

问题出在这里:

stat1.area = 78 866.2;
stat1.pop = 10 560 000;
Run Code Online (Sandbox Code Playgroud)

数字不应包含空格,因此只需删除它们,代码就应该编译.

如果您实际上正在编写C++代码(版本14或更高版本),您可以使用数字分隔符(浮点数整数数字文字)对它们进行分组,使它们具有良好的可读性:

stat1.area = 78'866.2;
stat1.pop = 10'560'000;
Run Code Online (Sandbox Code Playgroud)