#include <iostream>
struct Candybar
{
char name [50];
float weight;
int calories;
};
void candyshow (...);
void candyfill (Candybar & candy, constchar * name1 = "Millenium Munch", float weight1 = 2.85, int calories1 = 350);
int main()
{
Candybar x;
candyfill(x);
candyshow(x);
return 0;
}
void candyshow (Candybar & candy)
{
some codes here
}
void candyfill (Candybar & candy, constchar * name1, float weight1, int calories1)
{
std::cout << "Enter the name of the candy: ";
std::cin.getline(candy.name, 50);
std::cout << "Enter the weight of the candy: ";
std::cin >> candy.weight;
//std::cin.get();
std::cout << "Enter the calories of the candy: ";
std::cin >> candy.calories;
//std::cin.get();
I know the code works fine, but when I want it to show the default values (by pressing enter only), the display just shows a blank. Is my understanding of default values wrong?
When I include "candyfill()", the complier says this:
18:12: error: too few arguments to function 'void candyfill(Candybar&, const char*, float, int)'
11:6: note: declared here