-1

what does asterisk(*++argv) mean?

void main (int argc, char *argv[])
{
 while (--argc)              
  {
    printf ("%s\n", *++argv);
  }

}
kovac
  • 307
  • 4
  • 11
  • It's just the normal dereference operation. https://en.cppreference.com/w/c/language/operator_member_access – Mike Lui Dec 30 '18 at 19:16
  • it is about the pointer? OK, i got it. – kovac Dec 30 '18 at 19:17
  • 1
    Possible duplicate of [Regarding 'main(int argc, char \*argv\[\])'](https://stackoverflow.com/questions/3898021/regarding-mainint-argc-char-argv) – Hasan Dec 30 '18 at 19:20
  • I just dont have any knowledge about the pointer, but i know pointer. I didn't find that it was pointer. – kovac Dec 30 '18 at 19:28

2 Answers2

1

here argv is a pointer to a pointer of char type

*argv points to the first argument string in the argv array, which is same as argv[0], similarly *(argv + 1) and argv[1] point to second argument string and so on..

Pointers in C: when to use the ampersand and the asterisk?

Auxilus
  • 217
  • 2
  • 9
  • `argv` is `char*[]`, not just `char*` . Perhaps you could explain how the code iteratees through its arguments, and post a runtime example. That would make this a better answer. – erik258 Dec 30 '18 at 19:21
0

argv stands for argument vector and it holds argc + 1(int - argument count and the last one is NULL by default.) number of elements. Like in the char arrays, first element of the argument vector holds the address for the whole argument vector. So, by passing argument vector pointer (*argv[]), program gets the char typed parameters when main function is called.

To see how to get argument vector parameters and use them please check out this answer.

Hasan
  • 1,243
  • 12
  • 27