Question: My application has potentially a huge number of arguments passed in and I want to avoid the memory of hit duplicating the arguments into a filtered list. I would like to filter them in place but I am pretty sure that messing with argv array itself, or any of the data it points to, is probably not advisable. Any suggestions?

Answer: 
Some libraries do this!

The initialization method provided by the glut opengl library [(GlutInit)](https://www.opengl.org/resources/libraries/glut/spec3/node10.html) scans for glut related arguments, and clears them by moving the subsequent elements in `argv` forward (moving the pointers, not the actual strings) and decrementing argc

> 
> 2.1
> 
> 
> glutInit glutInit is used to initialize the GLUT library.
> 
> 
> Usage
> 
> 
> void glutInit(int \*argcp, char \*\*argv);
> 
> 
> argcp
> 
> 
> A pointer to the
>  program's unmodified argc variable from main. Upon return, the value
>  pointed to by argcp will be updated, because glutInit extracts any
>  command line options intended for the GLUT library.
> 
> 
> argv
> 
> 
> The program's
>  unmodified argv variable from main. Like argcp, the data for argv will
>  be updated because glutInit extracts any command line options
>  understood by the GLUT library.
> 
> 
>
The only time I would say that directly manipulating argv is a *bad* idea would be when an application changes its behavior depending on the contents of argv[0].

However, changing a program's behavior depending on argv[0] is in itself a very *bad* idea where portability is a concern.

Other than that, you can treat it just like you would any other array. As Jonathan said, GNU getopt() permutes the argument list non-destructively, I've seen other getopt() implementations that go as far as serializing and even hashing the arguments (useful when a program comes close to ARG\_MAX).

Just be careful with your pointer arithmetic.