Is it possible to change argv or do I need to create an adjusted copy of it?

ojblass picture ojblass · Jun 8, 2009 · Viewed 23.7k times · Source

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

Michael Burr picture Michael Burr · Jun 8, 2009

The C99 standard says this about modifying argv (and argc):

The parameters argc and argv and the strings pointed to by the argv array shall be modifiable by the program, and retain their last-stored values between program startup and program termination.