strtok() basically modifies the input string.
char *glob2 = "/abc/def/ghi";
In the above case, it glob2points to read-only data, and therefore it fails, whereas with ' char glob[] = "/abc/def/ghi";data is not read-only, it is available in a char array. Therefore, it is subject to modification.
source
share