getting error could not convert '5074798' from 'int' to 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}'|

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

struct TTcell
{
string days[]={'Mon','Tue','Wed','Thur','Fri'};
string Subject[10][10];
string Lecturer[10][10];
string RoomNo[10][10];
string timee[]={'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;
string tm;
string dy;
};
int ClearTimetable( TTcell cl)
{


for(int i=0;i<cl.n;i++)
{
for(int j=0;j<cl.m;j++)
{
cl.Subject[i][j]='NULL';
cl.Lecturer[i][j]='NULL';
cl.RoomNo[i][j]='NULL';
}

}
cout<<"\n\n Timetable :\n";
for(int k=0;k<6;k++)
for(int i=0;i<cl.n;i++)
{

for(int j=0;j<cl.m;j++)
{

cout<<cl.days[k];
cout<<cl.Subject[i][j]<<"\n";
cout<<cl.Lecturer[i][j]<<"\n";
cout<<cl.RoomNo[i][j]<<"\n";


}


}

}
int inserttimetable( TTcell cl)
{

cout<<"\nEnter Subject,Lecturer and RoomNO:\n";
for(int i=0;i<cl.n;i++)
{
for(int j=0;j<cl.m;j++)
{

cin>>cl.Subject[i][j];
cin>>cl.Lecturer[i][j];
cin>>cl.RoomNo[i][j];
}
}

}
int show(TTcell 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 (Monday,Tuesday,Wednesday,Thursday,Friday):\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;
}
}
cout<<" \nLecturer,Subject and Room no is:\t";

cout<<cl.Subject[cl.z][cl.a]<<"\t";
cout<<cl.Lecturer[cl.z][cl.a]<<"\t";
cout<<cl.RoomNo[cl.z][cl.a]<<"\n";


}
}

int showtimetable(TTcell cl)
{
cout<<"TIMETABLE:\n";
for(int q=0;q<10;q++)
{
cout<<cl.timee[q]<<"\t";
}
for(int k=0;k<6;k++)
for(int i=0;i<cl.n;i++)
{
for(int j=0;j<cl.m;j++)
{

cout<<cl.Subject[i][j];
cout<<cl.Lecturer[i][j];
cout<<cl.RoomNo[i][j];
}
}
}
int main()
{
TTcell cl;
cout<<"\nEnter No of Rows and Coloumns\n";
cin>>cl.n;
cout<<"/n";
cin>>cl.m;
cout<<"Choose the option:\n";
cout<<"1.Clear Timetable\n";
cout<<"2.Insert Timetable\n";
cout<<"3.Show \n";
cout<<"3.Show Timetable\n";
cin>>cl.ch;
switch(cl.ch)
{

case 1: ClearTimetable(cl);
break;
case 2: inserttimetable(cl);
break;
case 3: show(cl);
break;
case 4: showtimetable(cl);
break;
}

}
Use double quotes for strings (e.g. "Mon").
Single quotes are for single characters (e.g. 'M').
now its saying
error: too many initializers for 'std::string [0] {aka std::basic_string [0]}'
string days[]={"Mon","Tue","Wed","Thur","Fri"};
Last edited on
I think the array size needs to be explicitly specified for members of structs and classes.

 
string days[5]={"Mon","Tue","Wed","Thur","Fri"};
Last edited on
Topic archived. No new replies allowed.