I have 2 strings: 'name1' and 'name2'.
name1 is always of type something.inp and I want name 2 to be of type something.pts.
so if name1 is 'data.inp', i wanted name2 to be 'data.pts'. I tried doing the following, but with no success, since when I print name2 I get some garbage values right before 'pts'.
name1=(char*)malloc((strlen(argv[2])+1)*sizeof(char));
name2=(char*)malloc(1+(strlen(name1))*sizeof(char));
strcpy(name1, argv[2]);
strncpy(name2, name1, strlen(name1)-3);
strcat(name2, "pts");
Help will be greatly appreciated.