So, man says getopt() takes char * const argv[], which is an array of constant pointers to char, as far as I understand. At the same time, getopt() permutes argv, so that eventually all non-options are at the end of the array.
I find it very confusing, because it now has to swap strings character by character instead of just swapping pointers, or so. Why doesn’t it take just char * argv[]?
>Solution :
From the man page for Linux:
Conforming To
POSIX.2 and POSIX.1-2001, provided the environment variablePOSIXLY_CORRECTis set. Otherwise, the elements ofargvaren’t reallyconst, because we permute them. We pretend they’reconstin the prototype to be compatible with other systems.
So you can omit the const qualifier on Linux.