#include <iostream>

#include <string>


using namespace std;

bool isMagicDate(int month, int day, int year)

{

if (month*day == year)

return true;

else

return false;

}

int main()

{

string date;

cout << "Enter the date in the format mm/dd/yy ";

getline(cin, date);


int pos = date.find("/");

int pos1 = date.find("/", pos + 1);


string month = date.substr(0, 2);

cout << "month is " << stoi(month) << endl;


string day = date.substr(pos + 1, 2);

cout << "day is " << stoi(day) << endl;


string year = date.substr(pos1 + 1, 2);

cout << "year is " << stoi(year) << endl;


bool magic = isMagicDate(stoi(month), stoi(day), stoi(year));

if (magic == true)

cout << date << " is a magic date" << endl;

else

cout << date << " is not a magic date" << endl;

return 0;

}



코드인데 substr이 (시작지점, 개수) 이잖어


month에 한 자리수만 넣을경우 1/ 가 출력될줄 알았는데 1만 출력되는 이유가 뭐야???