Code:
#include<iostream.h>
#include<conio.h>
class date
{
int dd,yy,day,*incr;
char *mon; //first latter
public:
void setptr(date *m);
void getdata();
void putdata();
};
void date::setptr(date *m)
{
char *month[]={"jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"};
for(int i=0;i<=11;i++)
{
if(*m==*month[i])
{
*incr=*month[i];
cout<<*incr;
break;
}
}
}
void date::getdata()
{
date s;
cout<<"enter in dd,mon,yy foramt";
cout<<"\nenter day:";
cin>>dd;
cout<<"enter month";
cin>>mon;
cout<<"enter year";
cin>>yy;
cout<<"enter no.of days you want to enter:";
cin>>day;
s.setptr(mon);
}
void date::putdata()
{
cout<<endl;
cout<<"DATE:"<<dd<<":"<<mon<<":"<<yy;
}
void main()
{
clrscr();
date d1;
d1.getdata();
getch();
}
Comment