As already stated in the comments and solved by the OP: when checking the number of arguments, you may not continue and use the arguments anyway if the check fails. To pass arguments to the program from within VS, see this question.
solved Why does my program stop with an error message?