Hi,i have this code that i need to turn in for my homework.
I based it off some things i saw on the internet.
The point of the homework is that i need to have 2 or more structures and use some functions.

It would mean a lot if someone could help me fix it,im very new at programing and cant quite wrap my head around some things.
Heres the code.

#include <iostream>
using namespace std;

struct Product
{
    char name[50];
    int amount;
    float weight;
};
struct Market
{
    char nameofmarket[100];
};
Market chooseMarket(Market);
Product getData(Product);
void displayData(Product, Market); 
int main()
{
    Product p;
    Market m;
    m = chooseMarket(m); main.
    p = getData(p); 
    displayData(p, m);
    cout << "Totali: " << p.weight * 5 << " $" << endl;
    return 0;
}
Market chooseMarket(Market m)
{
    cout << "Enter the name of the Market you want to visit: ";
    cin.getline(m.nameofmarket, 100);
    return m;
}
Product getData(Product p) {

    cout << "Enter name of the fruit/vegetable: ";
    cin.get(p.name, 50);
    cout << "Enter amount: ";
    cin >> p.amount;
    cout << "Enter weight(in kg): ";
    cin >> p.weight;
    return p;
}
void displayData(Product p, Market m)
{
    cout << "\nDisplaying Information." << endl;
    cout << "\n" << m.nameofmarket << " Market" << endl;
    cout << "Product Name: " << p.name << endl;
    cout << "Amount: " << p.amount << endl;
    cout << "Weight: " << p.weight << endl;
}

Can't fix it if we don't know what's broken.

commented: My bad,on line 21,22 it says"error C4700 : uninitialized local variable used" +0

on line 21, remove main. that comes after the semicolon.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.