Say there is a common c array of type char *. I want to replace the value of a specific element, say index 0, by replacement. My code results in a segfault. What is the problem?
#include <string.h>
char * data[] = {
"aaa",
"bbb",
"ccc"
};
int main(int argc, char *argv[])
{
char * replacement = "xxx";
strncpy(data[0], replacement, 3);
return 0;
}