问题
我正在编写以下代码,如下面摘录的那样,应根据每种硬币的数量返回总金额.
static int qNum = 0;
static int dNum = 0;
static int nNum = 0;
static int pNum = 0;
int main(){
float totalCost;
totalCost = totalMoneyCalc();
}
float totalMoneyCalc(void){
float total;
total = qNum*.25 + dNum*.10 + nNum*.05 + pNum*.01;
return total;
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误
note: previous implicit declaration of ‘totalMoneyCalc’ was here
totalCost = totalMoneyCalc();
error: conflicting types for ‘totalMoneyCalc’
float totalMoneyCalc(){
Run Code Online (Sandbox Code Playgroud)
但是,当我删除totalMoneyCalc()函数的"float"部分时,它不会再返回任何错误.你不应该分配函数类型吗?
我试过的
我在SO上查看了这个问题,其中提到了一些关于必须传入void作为函数的参数的事情,这些函数除了将原始代码添加到原始代码之外不起作用.我还检查了一些关于在C中使用浮动函数的引物,但我遵循了这些并且它仍然不起作用.我应该用指针做点什么吗?我不明白为什么返回一个要赋值给变量的函数中的值与浮点数不同.如果有人有建议,修正或解释,我真的很感激.
我们在其中一个网页的HTML中有以下代码.我们尝试使用下面的PHP代码中显示的MySQL调用和while循环显示数据库中的所有Wifi速度和GPS位置.但是,它不会向页面返回任何内容.我们将echo语句放在PHP的各个部分(例如,在while循环之前,在数据库之前),它甚至不会将这些语句打印到网页上.
<body>
<h2>WiFi Speeds in the System</h2>
<p>Speeds Recorded in the System</p>
<?php
$username = "root";
$password = "";
$hostname = "localhost";
$dbc = mysql_connect($hostname, $username, $password)
or die('Connection Error: ' . mysql_error());
mysql_select_db('createinsertdb', $dbc) or die('DB Selection Error' .mysql_error());
$data = "(SELECT Wifi_speed AND GPS_location FROM Instance)";
$results = mysql_query($data, $dbc);
while ($row = mysql_fetch_array($results)) {
echo $row['Wifi_speed'];
echo $row['GPS_location'];
}
?>
</body>
Run Code Online (Sandbox Code Playgroud) 我使用以下命令安装Homebrew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Run Code Online (Sandbox Code Playgroud)
然后将其作为错误返回:
It appears Homebrew is already installed. If your intent is to reinstall you should do the following before running this installer again:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
Run Code Online (Sandbox Code Playgroud)
当我在终端中运行该命令时,我只是"找不到Homebrew!"