Let user input date in dd/mm/yyyy format

Well, as the title said, I want to know how to let the user input the date in dd/mm/yyyy format and get the day, month and year as separate integer numbers to work with them later. Here is what I have:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
	char day[3],month[3],year[5];
	cout<<"Please input the date in dd/mm/yyyy format:";
	cin.get(day,3,'/');
	cin.ignore(100,'/');
	cin.get(month,3,'/');
	cin.ignore(100,'/');
	cin.get(year,5);
	
	//convert them to int
	int d,m,y;
	d=atoi(day);
	m=atoi(month);
	y=atoi(year);
)


It seems to be working but can you please tell me are there better alternatives? I'm not allowed to use string class or <time.h> library by the way.
Thank you for your help
Try declaring the variables as ints and use the extraction operator (>>).
Topic archived. No new replies allowed.