vendredi 23 mars 2018

Program doesn't stop after returning 0 from main

I wrote a program that encodes files with Huffman coding.
It works fine but for some reason after returning 0 from main function it doesn't stop.
Main function looks like:

int main(int argc, char *argv[])
{
    if (argc < 5)
    {
        std::cout << "..." << std::endl;
    }
    else
    {
        if (!std::strcmp(argv[1], "haff") && !std::strcmp(argv[2], "-c"))
            HuffmanC(argv[3], argv[4]);
        if (!std::strcmp(argv[1], "haff") && !std::strcmp(argv[2], "-d"))
            HuffmanD(argv[3], argv[4]);

        std::cout << "Operations: " << count << std::endl;
    }

    return 0;
}

When I run it, I get:

MacBook-Pro-Alex:code alex$ ./main haff -c test.txt test.haff
Operations: 37371553

It ends with an empty line and terminal says that the program keeps running, but the last cout statement executes well and as I get it it should return 0 and finish. How can I make it finish after returning 0? Or is the problem in the rest of the code?

Aucun commentaire:

Enregistrer un commentaire