Advertisement
xeritt

Rename type file

Oct 18th, 2019
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define N 256
  4. /*
  5.     Hello.txt - > Hello.xyz
  6. */
  7. void renameTypeFile(char src[], char dest[], char *needle, char *text){
  8.     int c = strcspn(src, needle);
  9.     strncpy(dest, src, c);
  10.     strcat(dest, text);
  11. }  
  12.    
  13. int main(int argc, char **argv)
  14. {
  15.     char str[] = "Hello.txt";
  16.     char str2[N] = {'\0'};
  17.     renameTypeFile(str, str2, ".", ".xyz");
  18.     printf("%s", str2);
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement