you right anon
i have date struct (day, mounth ,year) time is string i tried
if(AppointmenList[currentSize].appdate == AppointmenList[k].appdate)
but didn`t work and incrementing currentSize once now
i couldnt figure out how im gonna use this
Code:
if ( )
{
if ( )
{
if ( )
{
/*.....*/
if ( )
{
/*Your code here*/
}
/*.....*/
}
}
}
here is my codes i still have problem with
//check if there an Appointment on the same Date and Time!
i can add more then one record on the same date and time which is not supposed to happen
Code:
void addAppointmentRecords( )
{
int number;
system("cls"); //clear screen
cout<<"\nHow many Appointments do you wish to add ";
cin>>number; //read number
cin.get(); //read newline character left in the buffer
if((number + currentSize ) <= listSize)//There is still room in the array
{
for(int i = 1; i<=number; i++)
{
cout<<"\nEnter Person name: ";
getline(cin, AppointmentList[currentSize].name);
cout<<"Enter Appointment Descriptions: ";
getline(cin, AppointmentList[currentSize].description);
cout<<"Enter Appointment date: ";
cin>>AppointmentList[currentSize].appdate.day;
cin>>AppointmentList[currentSize].appdate.mounth;
cin>>AppointmentList[currentSize].appdate.year;
cin.get(); //read a character
cout<<"Enter Appointment time: ";
getline(cin, AppointmentList[currentSize].time);
cout<<endl;
currentSize += 1; //update CurrentSize
for(int k=0; k<=currentSize; k++)
{ //check if there an Appointment on the same Date and Time!
if( AppointmentList[currentSize].appdate.day == AppointmentList[k].appdate.day &&
AppointmentList[currentSize].appdate.mounth == AppointmentList[k].appdate.mounth &&
AppointmentList[currentSize].appdate.year == AppointmentList[k].appdate.year &&
AppointmentList[currentSize].time == AppointmentList[k].time )
{
cout<<"\nGot a match\n";
cout<<"Appointment Date and Time already filled"<<endl;
currentSize -= 1; //update CurrentSize
cin.get();
}
else
{
cout<<"Apointment accepted"<<endl;
cin.get(); //read a character
break;
}
}
}
}
else
{
cout<<"Overflow!!!! Appointment List is full"<<endl;
cout<<"\nPress any key to continue"<<endl;
cin.get(); //read a character
}
}