i am new on Linux. I want to ask that how to store a command line argument in a character array. I am using the following code from an hour but I am unable to solve this problem(Segmentation fault Core Dumped). Here is the code
int main(int argc, char **argv[]) {
char * MyIp[15];
int j = 0;
while(argv[1][j] != '\0') {
MyIp[j] = argv[1][j++];
}
printf("IP : %s\n", *MyIp);
return 0;
}
and command line argument
./code.o "127.0.0.1"
Segmentation fault(core dumped)