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!