0

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.

3
Contributors
2
Replies
26
Views
4 Years
Discussion Span
Last Post by Suzie999
0

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.

0

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

Edited by Suzie999

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.