Substrings of argv

(Please correct my statements/assumption if wrong. Thanks.)

Assume the first argument of a command is "-argvone".

Hence argv[1] is the address to the string "-argvone".

Therefore it is the address of the first character, i.e. argv[1] is &argv[1][0] and *argv[1] is argv[1][0]

If I want just to skip the prefix '-' I can use the address of 'a' which is &argv[1][1].

Question:
is there a more elegant way of indicating the address of 'a', without ampersand and square brackets?
You can pass the argument without the '-' sign or you can use argv[1]+1
Hummm...
I thought that argv[1]+1 is equivalent to argv[2], not to &argv[1][1]. Am I wrong?
Bazzy is correct.

You could do

1
2
3
vector<const char*> v( argv, argv + argc );
cout << v.front() << endl;
// etc. 


Topic archived. No new replies allowed.