+ 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

16th Mar 2021, 5:26 AM
Jawahirullah
Jawahirullah - avatar
2 Respuestas
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
16th Mar 2021, 6:34 AM
DHANANJAY PATEL
DHANANJAY PATEL - avatar
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
16th Mar 2021, 6:36 AM
Jawahirullah
Jawahirullah - avatar