我在這個網站上看到了這兩個錯誤,並試圖更改我的代碼以適應建議的更改,但它們不適用於我的代碼,所以這裏是我的代碼,我希望你們能幫助我。它並不完整,因爲我只完成了任務的一半,但我看不到我迄今爲止所做的工作,因爲它無法正確構建。謝謝!錯誤LNK2019:無法解析的外部符號,致命錯誤LNK1120:1無法解析的外部
#include <stdio.h>
//int CheckMoney(double *payment, double item_cost); //compares the amount the user has deposited to the price of item selected. It returns 1 if the amount is at least enough to cover the cost, 0 if there is not enough.
//void GetMoney(double *payment, double item_cost, char selection); //calls CoinMenu function to collect money from the user and CheckMoney function to keep comparing the deposited amount to the item cost.
//void GetChange(double *payment, double item_cost, double *change); //calculates the amount of change to be returned
void CoinMenu(double *payment);
void Quit(char *again);
void GetCost(char selection, double *item_cost);
void Menu(char *selection);
// Displays the list of snack items and prompts for the user’s choice
void Menu(char *selection)
{
printf("Welcome to the AAA vending machine, where your wishes could come true for less than $2");
printf("/nWhich one of our delicious snacks would you like to sink your teeth into?");
printf("/nP – Potato Chips $1.25");
printf("/nS - Snickers Bar $1.35");
printf("/nT – Pop Tart $0.95");
printf("/nC – Cookies $1.50");
printf("/nB – Brownie $1.75");
printf("/nN – Nuts $1.40");
printf("Enter your delicious selection here: ",*selection);
scanf(" %c", &*selection);
//determine cost of selection
GetCost(*selection, 0);
}
//sets the cost of the purchase based on value in selection
void GetCost(char selection, double *item_cost)
{
if(selection=='P'||'p')
{
*item_cost=1.25;
}
else if(selection=='S'||'s')
{
*item_cost=1.35;
}
else if(selection=='T'||'t')
{
*item_cost=0.95;
}
else if(selection=='C'||'c')
{
*item_cost=1.50;
}
else if(selection=='B'||'b')
{
*item_cost=1.75;
}
else if(selection=='N'||'n')
{
*item_cost=1.40;
}
else
{
printf("That is not a valid selection, have a nice day!");
return;
}
}
//displays menu of coins and gets user input of the coins deposited
void CoinMenu(double *payment)
{
printf("Please deposit your money by the following numbers:");
printf("/n1 - $5.00");
printf("/n2 - $2.00");
printf("/n3 - $1.00");
printf("/n4 - $0.25");
printf("/n5 - $0.10");
printf("/n6 - $0.05");
printf("/n7 - $0.01");
printf("/nAmount deposited: ");
scanf(" %c", &*payment);
}
void Quit(char *again)
{
printf("Would you like to buy another snack?");
printf("/nEnter Y for yes or N for no: ", *again);
if(*again=='N'||'n')
{
return;
}
else if(*again=='Y'||'y')
{
void Menu(char *selection);
}
}
你的main()函數在哪裏? –
請發佈錯誤消息的副本/粘貼 - 您發佈的內容會留下一些可能很重要的細節。此外,可能與您的問題相關或不相關的一個問題是''Quit()'函數中的void Menu(char * selection)'行(在發佈代碼的末尾附近)僅僅是一個永遠不會獲取的聲明使用 - 這不是對'Menu()'函數的調用。 –