When started from VC6 IDE, I receive 7 arguments in argc/argv. When
started from console I receive 8 arguments in argc/argv. What should I do?
This is how I strat my console app from debugger:
-p1 -p2 -p3 -p4 -p5 -p6 -p7

This is how I start my console app from console:
TestApp -p1 -p2 -p3 -p4 -p5 -p6 -p7

I've tryed to add "TestApp" in a front of debugger argument list, but
then I have to change argv[3] into argv[4] in my app, if my app was invoked
from VC6 IDE, but I don't know if my console app was started from VC6 IDE or
console.

I'm using Windows XP Pro.

Re: main(int argc, char* argv[]) by Victor

Victor
Mon Jun 21 08:34:08 CDT 2004

Miki Peric wrote:
> When started from VC6 IDE, I receive 7 arguments in argc/argv. When
> started from console I receive 8 arguments in argc/argv. What should I do?

Display them all to understand where you get the extra argument.

> This is how I strat my console app from debugger:
> -p1 -p2 -p3 -p4 -p5 -p6 -p7

You mean this is your "command line arguments" setting in the project?
It should give you 8 arguments, numbered from 0 through 7, the 0th being
the actual program.

>
> This is how I start my console app from console:
> TestApp -p1 -p2 -p3 -p4 -p5 -p6 -p7
>
> I've tryed to add "TestApp" in a front of debugger argument list, but
> then I have to change argv[3] into argv[4] in my app, if my app was invoked
> from VC6 IDE, but I don't know if my console app was started from VC6 IDE or
> console.

Of course you don't. Figure out where the extra argument comes from and
you're going to be fine.

With all due respect, I think you have a typo in either one place or the
other or both. You think you have "-p1 ... -p7", but you are probably
missing one in the project.

>
> I'm using Windows XP Pro.

That shouldn't matter.

Victor