fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. const char *file_path = "D:/MyFolder/YetAnotherFolder/test.txt";
  5. const char *bk_string = ".bk";
  6. char *file_bk_path = malloc((strlen(file_path) + strlen(bk_string) + 1)*sizeof(char));
  7. if (!file_bk_path) { exit(1); }
  8. strcpy(file_bk_path, file_path);
  9. strcat(file_bk_path, bk_string);
  10. printf("%s\n", file_bk_path);
  11. free(file_bk_path);
  12. return 0;
  13. }
  14.  
Success #stdin #stdout 0s 4492KB
stdin
Standard input is empty
stdout
D:/MyFolder/YetAnotherFolder/test.txt.bk