I am not an hardcore C++ coder. i know few functions should not be used. but this program is for 16 bit Environment. I m using TC3.0 for this program. Program compiles successfully values are accepted Well. But some values Jumbling in Dates _________________________________________ //Few include file may be Extra, since only snippet of code is pasted. #include"iostream.h" #include"conio.h" #include"stdio.h" #include"string.h" #include"stdlib.h" #include"fstream.h" #include "dos.h" dispd(date ); class prd { public: char name[25],addr[40],phno[12],rdno[8]; date dop,lppd,dom; int nopp; void setval() { cout<<"\n Enter Name of Client: "; gets(name); cout<<"\n Enter Address of Client: "; gets(addr); cout<<"\n Enter Contact Number of Client : "; gets(phno); cout<<"\n Enter RD Number of client's Policy : "; gets(rdno); getdate(dop); getdate(lppd); cout<<"\n Age Of Policy : "; cin>>i; getdate(dom); dom.da_year+=i; nopp=1; } void disp() { cout<<"\n Name : "<<name<<"\n Address :"<<addr<<"\nContact number :"<<phno; cout<<"\n RD Number : "<<rdno<<"\nDate Of Policy : "<<dispd(dop); cout<<"\n Date Of Maturity : "<<dispd(dom); cout<<"\n Last Premium paid on "<<dispd(lppd); } }; dispd(date d1) { cout<<d1.da_day<<"-"<<d1.da_mon<<"-"<<d1.da_year; } void main() { prd p1; clrscr(); p1.setval(); p1.disp(); getch(); } Code (markup): _______________________________________ Waiting for your replies
Hi, I had a quick look. One thing that might be cause odd values to be output is lines like: cout<<"\n Last Premium paid on "<<dispd(lppd); Here you are passing to cout, the result of calling dispid. But dispid is probably returning an int. You are using an old Turbo C compiler that lets you get away with function prototypes like: dispd(date d1) { cout<<d1.da_day<<"-"<<d1.da_mon<<"-"<<d1.da_year; } which should really be: void dispd(date d1) { cout<<d1.da_day<<"-"<<d1.da_mon<<"-"<<d1.da_year; } I'm guessing that you sometimes get the date output first, followed by the text "Last premium ..." and then sometimes a rubbish value. Try changing the code to: cout<<"\n Last Premium paid on "; dispd(lppd); Hope this helps. Mike