u need to place..sscanf instead of scanf...to read the date..u can use
"%d/%d/%d"...
for further info..read this..
http://www.java-samples.com/showtutorial.php?tutorialid=564

On Tue, Aug 30, 2011 at 10:16 PM, rahul aravind <rahularavin...@gmail.com>wrote:

> can anyone explain the output of this program....
>
>
> #include<iostream>
> #include<stdio.h>
> #include<conio.h>
> using namespace std;
> class date
> {
>   int day,month,year;
> public:
>   date(char *str);
>   date(int m,int d,int y);
>   date::date();
>   void show();
> };
> date::date(char *str)
> {
>   scanf(str,"*c*cd",&month,&day,&year);
> }
> date::date(int m,int d,int y)
> {
>   day=d;
>   month=m;
>   year=y;
> }
> date::date()
> {
>   cout<<"Enter month_day_year:";
>   cin>>day;
>   cin>>month;
>   cin>>year;
> }
> void date::show()
> {
>   cout<<month<<'/'<<day<<'/';
>   cout<<year<<'\n';
> }
> main()
> {
>   date sdate("11/1/1999");
>   date idate(12,2,1998);
>   date indate;
>   sdate.show();
>   idate.show();
>   indate.show();
>   getch();
>   return 0;
> }
>
>
>
> output:1
> Enter month_day_year:2
> 3
> 1
> 5060224/108/27
> 12/2/1998
> 3/2/1
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
*Dheeraj Sharma*
Comp Engg.
NIT Kurukshetra
+91 8950264227

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to