Computer Science Canada

C++ Output

Author:  Hugetanks [ Fri May 17, 2019 8:23 pm ]
Post subject:  C++ Output

Hello, I just started learning C++ for competitive programming, and I'm confused with what my output gives me. Can someone tell me what's wrong with my code?

c++:
#include <iostream>

int main()
{
    int longer, counter = 0;
    char dummy;
    std::cin>>longer;
    char num[80];
   
    for (int i = 0; i < longer; i++)
    {
        std::cin.getline(num,80);
        dummy = num[0];
        for (int k = 0; k < sizeof(num)/sizeof(num[i]); k++)
        {
            if (num[k] == dummy)
                counter++;
            else
            {
                std::cout << counter << " " << dummy << " ";
                dummy = num[k];
                counter = 0;
            }
        }
        std::cout<<"\n";
    }
       
    return 0;
}


It's for this question: https://dmoj.ca/problem/ccc19j3 Thanks![/syntax]


: