C语言报错:error: expected ‘=‘, ‘,‘, ‘;‘, ‘asm‘ or ‘__attribute__‘ before ‘{‘ token|解决方法

9 篇文章 1 订阅
C语言写代码的时候碰到问题:
error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|

网上看大家出现这个错误有很多原因。这次解决了,记录一下。

报错原因:

翻译:语法错误,缺少了一些必要的符号。
注意检查:
1、注意检查头文件前的有没加井号“#”
2、声明函数的时候()后面有没加分号“;”

报错代码:

这里是函数声明第5行忘记了分号。

#include <stdio.h>
#include <stdlib.h>
#include<math.h>

void money(int year,int loan,float rate)
int main()
{
    int n,loan;
    float rate;
    printf("Input loan:");
    scanf("%d",&loan);
    printf("Input rate:");
    scanf("%f",&rate);
    for(n=5;n<=30;n++)
        money(n,loan,rate);
    return 0;
}
void money(int year,int loan,float rate)
{
    int loan,month;
    month = year*12;
    money = loan*rate(1+pow(1+rate,month))/(pow(1+rate,month)-1);
    printf("Year:%d  Money:%f\n",year,money)
}

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值