아래 소스에서
sscanf(str,"%d%*c%d%*c%d",&month,&day,&year);
여기서 왜 %c 로 하지 않고 %*c로 하는지 모르겠습니다.
#include<iostream.h>
#include<stdio.h>
class date{
int day,month,year;
public:
date(char *str);
date(int m,int d,int y){
day=d;
month=m;
year=y;
}
void show(){
cout<<month<<'/'<<day<<'/';
cout<<year<<'/';
}
};
date::date(char *str)
{
sscanf(str,"%d%*c%d%*c%d",&month,&day,&year);
}
main()
{
date sdate("11/1/92");
date idate(11,1,92);
sdate.show();
idate.show();
return 0;
}
|