I'm trying to remove the file extension from a file so I can rename the file with the substring "opt.s". I do this with following simple example program:
char in[5] = "hel.s";
char test[40];
strncpy(test,in,strlen(in)-2);
char result[50];
strcpy(result,strcat(test,"opt.s"));
printf(" %s ",result);
The output i get differs but usually looks something like the following:
helþ(opt.s
So basically random numbers appear in between "hel" and "opt.s". What is the cause of this? Did I use strcpy wrong or is strcat causing the problem?