I am writing a C program. It takes its arguments from commandLine. I want to change the commandLine arguments in the code. As they are defined as “const char *”, I can not change them using “strcpy”, “memcpy”, … Also, you know, I can not just change their type from “const char *” to “char *”.
Is there any way to change them?
Thank you so much in advance.
Best regards,
Shadi.
According to C99 §5.1.2.2.1/1, the signature for
mainisSo you are allowed to remove the
const. Just don’t cause a buffer overrun bystrcpying in longer strings than the original arguments, or attempting to install more arguments than originally passed.Everyone else is basically right that you should create a copy instead.