I found that main() allows overriding the argv[] parameters, because they are not const.
#include <cstdio>
int main(int argc, char** argv)
{
printf("%i %s\n", argc, argv[1]);
argv[1][0] = 'X';
argv[1][4] = 'X';
printf("%i %s\n", argc, argv[1]);
return 0;
}
And below is the result. It compiled and worked.
At first, I expected some program crush like undefined behaviour. However, it may make sense that I may want to have a program that accept sensitive data as parameter, but after I use it, I would like to override it it immediately. Is this is the only reason or there are others?
I would like to understand how this is working. I.e, where is the char** argv[] strings array located? How is it created and deleted? Etc.