searching for an argument. if the one of the arg equals "test" should output its index,otherwise should print "-1"
Example: arg1 arg2 test ---> should prints "2" or arg1 arg2 arg3 should prints "-1".Of course it could be much more input.
My problem starts here... -1 -1 2 instead of just "2".As you can see before "2" it prints 2 times "-1".I think because of arg1 and arg2.really i cant get it. Maybe because of loops, but how?
Nothing to do with command line arguments. It has to do with where you put the instruction to print −1. Work out where that instruction is and what the code around it is doing, and I think you will be able easily to solve your problem.