+ 3
How can i get date and month by the string separately.
The string is in the form of XX/YY/ZZZZ. https://code.sololearn.com/cDkDf1RqMG87/?ref=app
2 Antworten
0
M. Jawahirullah
String form has fix format
DD/MM/YYYY
cin >> date;
string year(date,6,4);
string month(date,3,2);
string day(date,0,2);
cout << day << endl;
cout << month << endl;
cout << year << endl;
one of the constructor of string takes 3 argument
string(str,offset,len);
str => is string to be processed
offset => is integer start position
len => is integer length after offset
DHANANJAY
0
Thank you for your answer but another thing is if i put date and month in single digit, how to get this accordig to user's choice of input