The following code block is producing and endless loop and I can't figure out why. Note that charv is just he second command line argument in the main function.

    int testNumber = 1;
    while(argv != '\0')
    {
        std::cout << testNumber;
        argv++;
        testNumber++;
    }

I wrote this piece of code just as a test to see if the loop could be controled using the '\0' element of the char array from the command line argument.

Recommended Answers

All 2 Replies

argv is not a char, it's a pointer to a pointer to a char, so the comparison argv != '\0' makes no sense. You really shouldn't be modifying argv directly by incrementing it anyway.

You are not incrementing argv index, nor are you testing argv index.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.