I am trying to copy argv to char array, been through some solutions online but ending up in getting Segmentation Fault. Following is the code i used:
void main (int argc,const char *argv[])
{
char *arr;
arr = (char *) malloc(strlen(argv[1])+1);
strcpy(arr,argv[1]);
}
Please help to identify what I am doing wrong.