command line arguments

if my commmand line arguments are
 
 myprog one two three

then the output of ++*++argv should be n according to me because these operators are right to left associative so ++argv implies (argv+1) and * specifies argv[1],then again a * means dereferencing and ++ implies +1 in that char array,however to my disappointment the ans is p,can any1 explain y?
It is as you described. Step thru this in the debugger.
1
2
3
4
5
6
7
8
9
10
11
12
13
int main(int argc, char** argv)
{
	char** p;

	p = argv;
	char** p1 = ++p;	// p1 = [one] [two] [three]

	p = argv;
	char*  p2 = *++p;	// p2 = one

	p = argv;
	char*  p3 = ++*++p;	// p3 = ne
}


The expression does point to 'n', but if you treat that as null terminated array of chars (a C string), you get "ne".
Last edited on
Topic archived. No new replies allowed.