getting error: invalid conversion from 'TTcell (*)[30][30]' to 'int' [-fpermissive] int insertdata (cl)

#include <iostream>
#include<string>
using namespace std;


struct TTcell
{
string days[5] = { "Mon", "Tue", "Wed", "Thur", "Fri" };
string Subject[60][60];
string Lecturer[60][60];
string RoomNo[60][60];
string timee[9] = { "0(9:00)", "1(10:00)", "2(11:00)", "3(12:00)", "4(1:00)", "5(2:00)","6(3:00)", "7(4:00)", "8(5:00)" };
int count = 0;
int n, m, z, a, ch, cd;
char c, g, as;
string tm;
string dy;

} cl[30][30];


int insertdata (cl)
{
cout << "Enter 000 if you want to leave blank\n";
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 10; j++)
{
cout << "Enter details for " << cl.days[i] << " " << cl.timee[j] << "\n";
cout << "Subject:\t";
cin >> cl[i][j].Subject;
cout << "\nLecturer:\t";
cin >> cl[i][j].Lecturer;
cout << "\nRoom No:\t";
cin >> cl[i][j].RoomNo;
}
}
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 10; j++)
{
if (cl[i][j].Subject == "000" || cl[i][j].Lecturer == "000"|| cl[i][j].RoomNo == "000")
{
cl[i][j].Subject == " ";
cl[i][j].Lecturer == " ";
cl[i][j].RoomNo == " ";
}
}
}
cout << "Want to print the Table:\n";
cout << setw (15) << "TIMETABLE\n";
for (int i = 0; i < 6; i++)
{
cout << setw (15) << cl[i].timee;

}
cout << "\n";
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 10; j++)
{
cout << setw (15) << cl[i][j].days << setw (15) << cl[i][j].
Subject << setw (15) << cl[i][j].
Lecturer << setw (15) << cl[i][j].RoomNo;

}
}
return 0;
}
int cleardata (cl)
{
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 10; j++)
{
cl[i][j].Subject == " ";
cl[i][j].Lecturer == " ";
cl[i][j].RoomNo == " ";
}
}
cout << setw (15) << "TIMETABLE\n";
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 10; j++)
{
cout << setw (15) << cl[i][j].timee;
}
}
cout << "\n";
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 10; j++)
{
cout << setw (15) << cl[i][j].days << setw (15) << cl[i][j].
Subject << setw (15) << cl[i][j].
Lecturer << setw (15) << cl[i][j].RoomNo;

}
}
return 0;

}
int show (cl)
{
cout << "\nEnter Time (0(9:00),1(10:00),2(11:00),3(12:00),4(1:00),5(2:00),6(3:00),7(4:00),8(5:00)):\n";
cin >> cl.tm;
cout << "Enter Day (Mon,Tue,Wed,Thur,Fri):\n";
cin >> cl.dy;
for (int i = 0; i < 10; i++)
{
if (cl.timee[i] == cl.tm)
{
cl.z = i;
}
for (int j = 0; j < 6; j++)
{
if (cl.days[j] == cl.dy)
{
cl.a = j;
}
}
}
return 0;

}
int showtimetable (cl)
{
cout << setw (15) << "TIMETABLE\n";
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 10; j++)
{
cout << setw (15) << cl[i][j].timee;
}
}
cout << "\n";
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 10; j++)
{
cout << setw (15) << cl[i][j].days << setw (15) << cl[i][j].
Subject << setw (15) << cl[i][j].
Lecturer << setw (15) << cl[i][j].RoomNo;


}
return 0;
}


int data (TTcell cl)
{
cout << "\nEnter No of Rows and Coloumns\n";
cin >> cl.n;
cout << "\n";
cin >> cl.m;
do
{
cout << "Choose the option:\n";
cout << "1.Clear Timetable\n";
cout << "2.Insert Timetable\n";
cout << "3.Show \n";
cout << "4.Show Timetable\n";
cin >> cl.ch;
switch (cl.ch)
{

case 1:
Cleardata (cl);
break;
case 2:
insertdata (cl);
break;
case 3:
show (cl);
break;
case 4:
showtimetable (cl);
break;
}
cout << "Do you want to access the menu?\n";
cin >> cl.c;
}
while (cl.c == 'y' || cl.c == 'Y');
return 0;
}
int main ()
{
TTcell cl;
do
{

cout << "Enter the Timetable you want to access:\n";
cout << "1.Winter\n";
cout << "2.Spring\n";
cout << "3.Summer\n";
cout << "4.Autumn\n";
cin >> cl.cd;
switch (cl.cd)
{
case 1:
cout << "Timetable for Winter\n";
data (cl);
break;
case 2:
cout << "Timetable for Spring\n";
data (cl);
break;
case 3:
cout << "Timetable for Summer\n";
data (cl);
break;
case 4:
cout << "Timetable for Autumn\n";
data (cl);
break;
}
cout << "Want to enter Timetable of other season?\n";
cin >> cl.g;
}
while (cl.g == 'y' || cl.g == 'Y');
return 0;
}
On what line?

Was it this?
1
2
3
4
5
6
7
8
9
10
TTcell cl[30][30];


for (int i = 0; i < 6; i++)
{
  for (int j = 0; j < 10; j++)
  {
    cout << "Enter details for " << cl.days[i] << " " << cl.timee[j] << "\n";
  }
}



PS. On main() you create TTcell cl; that masks the global TTcell cl[30][30];. Is that necessary obfuscation?
yes you are right. but then in main function should i create another object or what?
i m getting that error on this line


int insertdata (cl)
{
cout << "Enter 000 if you want to leave blank\n";
Last edited on
Lets have a function declaration:
int foo( bar );
What is the 'foo'? The name of function.
What is the 'bar'? The type of function's argument.

Again:
int foo( bar gaz );
What is the 'foo'? The name of function.
What is the 'bar'? The type of function's argument.
What is the 'gaz'? The name of function's argument.

Again:
int insertdata ( cl )
Is 'cl' a name of a type? It should be, but is it? What type of argument should this function take?
What is the name of the argument, whose type is 'cl'? We don't know.


Lets look at how we get to the insertdata(). At least one path:
The main():
1
2
TTcell foo;
data( foo );

The data()
1
2
3
4
int data( TTcell bar )
{
  insertdata( bar );
}

If insertdata() is called with TTcell argument, should it then be:
int insertdata ( TTdata gaz )


Why your functions return int even though they seem to return no useful data?

Why do you have global array cl?
Topic archived. No new replies allowed.