#include<iostream>
using namespace std;
struct time
{
int hours,minutes,seconds;
};
struct lecture
{
time stime;
int duration;
int room;
char building;
};
void clash(lecture l1, lecture l2)
{
if(l1.building==l2.building && l1.room==l2.room)
{
if(l1.stime.hours==l2.stime.hours &&
l1.stime.minutes==l2.stime.minutes &&
l1.stime.seconds==l2.stime.seconds)
{
cout<<"CLASH1"<<endl;
}
else if(l1.stime.hours>l2.stime.hours)
{
if((l2.stime.hours+l2.duration)>(l1.stime.hours))
{
cout<<"CLASH2"<<endl;
}
else
{
cout<<"NO CLASH1"<<endl;
}
}
else if(l1.stime.hours<l2.stime.hours)
{
if((l1.stime.hours+l1.duration)>=(l2.stime.hours))
{
cout<<"CLASH3"<<endl;
}
else
{
cout<<"NO CLASH2"<<endl;
}
}
else if(l1.stime.hours==l2.stime.hours)
{
if(l1.stime.minutes>l2.stime.minutes)
{
if((l2.stime.minutes+(l2.duration*60)>((l1.stime.m inutes))))
{
cout<<"CLASH4"<<endl;
}
else
{
cout<<"NO CLASH3"<<endl;
}
}
else if(l1.stime.minutes<l2.stime.minutes)
{
if((l1.stime.minutes+(l1.duration*60))>l2.stime.mi nutes)
{
cout<<"CLASH5"<<endl;
}
else
{
cout<<"NO CLASH4"<<endl;
}
}
else if(l1.stime.minutes==l2.stime.minutes)
{
if(l1.stime.seconds>l2.stime.seconds)
{
}
else if(l1.stime.seconds<l2.stime.seconds)
{
}
else if(l1.stime.seconds==l2.stime.seconds)
{
}
else
{
cout<<"NO CLASH5"<<endl;
}
}
else
{
cout<<"NO CLASH6"<<endl;
}
}
else
{
cout<<"NO CLASH7"<<endl;
}
}
else
{
cout<<"NO CLASH8"<<endl;
}
}
int main()
{
lecture l1, l2;
cout<<"Enter Building of First Lecture"<<endl;
cin>>l1.building;
cout<<"Enter Room of First Lecture"<<endl;
cin>>l1.room;
cout<<"Enter Start Time of the First Lecture in the format of hours,
minutes and then seconds"<<endl;
cin>>l1.stime.hours;
cin>>l1.stime.minutes;
cin>>l1.stime.seconds;
cout<<"Enter Duration of the First Lecture"<<endl;
cin>>l1.duration;
cout<<"Enter Building of Second Lecture"<<endl;
cin>>l2.building;
cout<<"Enter Room of Second Lecture"<<endl;
cin>>l2.room;
cout<<"Enter Start Time of the Second Lecture in the format of hours,
minutes and then seconds"<<endl;
cin>>l2.stime.hours;
cin>>l2.stime.minutes;
cin>>l2.stime.seconds;
cout<<"Enter Duration of the Second Lecture"<<endl;
cin>>l2.duration;
clash(l1,l2);
return 0;
}
This is code for the program which takes the information of two
lectures and determines wheher there is a clash between two lectures or
not. While compiling it with GCC i get error 'struct lecture' has no
member named 'stime' . It works fine with VC++. Please help me remove
the error using GCC.