Advertisement
anon20016

6

Dec 24th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void concat(char * a, char * b, int ind){
  6. if (ind > strlen(a)){
  7. return NULL;
  8. }
  9. char c[100] = "";
  10. int i = 0;
  11. for (i = 0; i < ind; i++){
  12. c[i] = a[i];
  13. }
  14. for (int j =0; j < strlen(b); j++){
  15. c[i] = b[j];
  16. i++;
  17. }
  18. for (int j = ind; j < strlen(a); j++){
  19. c[i] = a[j];
  20. i++;
  21. }
  22. c[i] = '\0';
  23. strcpy(a, c);
  24. }
  25.  
  26. int main()
  27. {
  28. char a[100] = "11111";
  29. char b[100] = "222";
  30. concat(a, b, 3);
  31. printf("%s", a);
  32.  
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement