本文介绍了错误:"预期'('字符串之前常数QUOT;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在计算值的几何平均值以阵列工作
该函数应计算地理正确的意思,但我发现了一个奇怪的错误讯息
的#include<&stdio.h中GT;
#包括LT&;&stdint.h GT;
#包括LT&;&math.h中GT;
为externC双GEOMEAN(双myArray的[],诠释计数)////错误在这里,预期'('字符串常量前
{
双GEOMEAN = 1;
双根=(1 /(双)数);
INT I;
对于(i = 0; I<计数;我++)
{
GEOMEAN = GEOMEAN * myArray的[I]
}
GEOMEAN = POW(GEOMEAN,根);
返回GEOMEAN;
}
解决方案
的externC
不是有效的C(这是唯一有效的在C ++中)。只是如果你在纯C的工作将其删除。
Working on computing the geometric mean of values in an array
The function should compute the geo mean correctly, but i'm getting a weird error message
#include <stdio.h>
#include <stdint.h>
#include <math.h>
extern "C"
double geomean(double myarray[], int count) ////error here, expected '(' before string constant
{
double geomean = 1;
double root = (1/(double)count);
int i;
for(i = 0; i < count; i++)
{
geomean = geomean * myarray[i];
}
geomean = pow(geomean, root);
return geomean;
}
解决方案
extern "C"
is not valid C (it's only valid in C++). Just remove it if you're working in pure C.
这篇关于错误:&QUOT;预期'('字符串之前常数QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!