"When to take medicine" CodeChef Challenge MEDIC I just submitted this code to solve the "When to take medicine" challenge on CodeChef:

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;sstream&gt;

int countDays(int dd, int subtract)
{
    return ((subtract - dd) / 2) + 1;
}

int main()
{
    int t {0};
    std::cin &gt;&gt; t;
    std::cin.ignore();
    while (t--)
    {
        std::string date {};
        std::getline(std::cin, date);
        std::stringstream ss {date};
        int yy {0}, mm {0}, dd {0};
        std::string temp {};
        std::getline(ss, temp, ':');
        yy = std::stoi(temp);
        std::getline(ss, temp, ':');
        mm = std::stoi(temp);
        std::getline(ss, temp, ':');
        dd = std::stoi(temp);
        int subtract {0};
        bool leap {false};
        if (yy % 4 == 0 &amp;&amp; (!(yy % 100 == 0) || yy % 400 == 0))
        leap = true;
        switch (mm)
        {
        case 2:
            if (leap)
                subtract = 29;
            else
                subtract = 59;
                break;
        case 4: case 6: case 9: case 11:
            subtract = 61;
        break;
        default:
            subtract = 31;
        }   
        std::cout &lt;&lt; countDays(dd, subtract) &lt;&lt;'\n';
    }
}


In short, it is a program to tell how many days a guy has took his pill correctly, considering that he has to take a pill every 2 days and only takes it in odd or even days, depending on the day he started to take the pill. We provide a number of test cases in the first line and then we provide a date in a single line in the format yyyy:mm:dd. Check the link above if you're interested in reading the whole problem. 

The thing is that I am not really satisfied with the way I am parsing the string separated by the char :

I also want to mention that I want to stay away from any C code like the scanf() function. It would make things a lot easier, but I don't want to use C in C++. 

So, how could I redesign my string parse code to make it look nicer? I am just a newbie with C++ so all feedback / criticism is greatly appreciated.
You don't check whether the input is invalid.
Try to extract useful well-named functions, like int days(int month, int year) and bool is_leap_year(int year).
You can extract the numbers directly from std::cin, the colon will be left behind.
And the colon can thereafter be extracted like any other single character.
As an aside, using scanf() would probably be easier than juggling streams.
break should be indented like any other Statement. It does not deserve more indentation (first occurrence), nor less (second occurrence).