12 Mart 2010 Cuma

C++ Date Example

//www.ethemsulan.com
#include <cstdlib>
#include <iostream>
#include <cstdio>
using namespace std;
class date{
      int day,month,year;
      public:
             date(char *str);
             date(int d,int m,int y){
                      day=d;
                      month=m;
                      year=y;
                      }
             void show(){
                  cout<<day<<' '<<month<<' '<<year<<endl;
                  }
      };
date::date(char *str){
                sscanf(str,"%d%*c%d%*c%d",&day,&month,&year);
                }
int main(int argc, char *argv[])
{
    date sdate("01/11/2008");
    date idate(01,11,2008);
    sdate.show();
    idate.show();
    system("PAUSE");
    return EXIT_SUCCESS;
}

Hiç yorum yok:

Yorum Gönder