Can I pass a const char* array to execv?
问题 This is the prototype for execv : int execv(const char *path, char *const argv[]); Can I pass an array of const char pointers as the second argument? This example program gives a warning when USE_CAST is not set: #include <unistd.h> int main(int argc, char *argv[]) { if (argc > 0) { const char *exe_name = "/bin/echo", *message = "You ran"; const char *exe_args[] = { exe_name, message, argv[0], NULL }; #ifdef USE_CAST execv("/bin/echo", (char **) exe_args); #else execv("/bin/echo", exe_args);