0
votes

I'm a newb to C++ and I get the following error. I looked up similar topics, but didn't find the answer I need. Here is the script, the error is in line 23:

#include <iostream>
#include <string>

using namespace std;

struct rendeles {
    string nev;
    int mennyiseg;
};

struct teaceg {     
    string nev;
    int mennyiseg;
};

int szam; 

int hanyadikceg (string cegnev); 
{            //line 23
    for (int i=0;i<szam;i++)
    {
        if (cegek[i].nev==cegnev)
            {
                return i;
            }
    }
    return -1;
}

void osszesit()
{
    for (int i=0;i<szam;i++)   
    {

    }
}

int main()
{
    cout << "Hány db rendelés lesz összesen?";
    cin >> szam;

    struct teaceg cegek [szam];
    struct rendeles rendelt [szam];     

    for (int i=0;i<szam;i++)          
    {
        cout << "A(z) " << i+1 <<". cég neve:";
        cin >> rendelt[i].nev;
        cout << "A(z) " << i+1 <<". rendelés mennyisége:";
        cin >> rendelt[i].mennyiseg;
    }

    cout << endl;
    for (int i=0;i<szam;i++) 
    {
        cout << "A(z) " << i+1 << ". rendelés: " << rendelt[i].nev << " " << rendelt[i].mennyiseg << endl;
    }

    return 0;
}

Sorry for the foreign identifiers :-)

Thanks for all the help! Such a newbie mistake :-)

I still have a problem though: I want "cegek" and "rendelt" be dynamic arrays. So they can't be global variables. But in the function "hanyadikceg" I need to get their data. Could you show me pls how to pass the variables to the function properly? (what to write inside the "()" of the function "hanyadikceg") Thanks!

2
The semicolon turns the function header into a function prototype. The point of prototypes is that they don't have bodies. - chris

2 Answers

8
votes

Remove the semicolon

int hanyadikceg (string cegnev); 
{

should become

int hanyadikceg (string cegnev)
{
2
votes

Remove the semicolon from the end of line 22.