Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- void concat(char * a, char * b, int ind){
- if (ind > strlen(a)){
- return NULL;
- }
- char c[100] = "";
- int i = 0;
- for (i = 0; i < ind; i++){
- c[i] = a[i];
- }
- for (int j =0; j < strlen(b); j++){
- c[i] = b[j];
- i++;
- }
- for (int j = ind; j < strlen(a); j++){
- c[i] = a[j];
- i++;
- }
- c[i] = '\0';
- strcpy(a, c);
- }
- int main()
- {
- char a[100] = "11111";
- char b[100] = "222";
- concat(a, b, 3);
- printf("%s", a);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement