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:
#include <iostream>
#include <string.h>
usingnamespace 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