错误:在‘之前应为表达式;双倍’;。Can';使幂函数不起作用
我正在做一个基本的计划,我会给你我的贷款利率后 指定的年数。为此,我需要使用幂公式错误:在‘之前应为表达式;双倍’;。Can';使幂函数不起作用,c,C,我正在做一个基本的计划,我会给你我的贷款利率后 指定的年数。为此,我需要使用幂公式 totalLoanBalance = Double pow(interestRateAndPrincipal, yearsOutstanding) * LoansTaken; 但是当我输入这个信息时,我得到了这个错误 error: expected expression before ‘double’ totalLoanBalance = double pow(interestRateAndP
totalLoanBalance = Double pow(interestRateAndPrincipal, yearsOutstanding) * LoansTaken;
但是当我输入这个信息时,我得到了这个错误
error: expected expression before ‘double’
totalLoanBalance = double pow(interestRateAndPrincipal, yearsOutstanding) * loansTaken;
^
我尝试过在括号中的变量前面加上double,以及其他一些策略,但我似乎无法修复它。我也不明白错误告诉了我什么。谢谢您的帮助。调用函数时,您不需要指定函数的返回类型,只有在定义或声明函数时才需要指定
totalLoanBalance = pow(interestRateAndPrincipal, yearsOutstanding) * LoansTaken;
这误解了C的函数调用语法。在调用函数时,您没有命名返回类型
totaloanbalance=pow(…
是正确的。当我取出double时,我在函数main:loans.c:(.text+0xaf)中得到此错误消息:未定义对pow集合的引用2:错误:ld返回1退出status@DominicPelini那是因为你没有链接到数学库,而数学库就是pow
所在的地方。在编译时将-lm
添加到命令行。@DominicPelini很高兴我能帮上忙。如果你觉得有用,请随意。