insert string in string java
String newString = originalString.substring(0, index + 1)
+ stringToBeInserted
+ originalString.substring(index + 1);
insert string in string java
String newString = originalString.substring(0, index + 1)
+ stringToBeInserted
+ originalString.substring(index + 1);
String insertion into another string
// Insert q char c in pos n of the string str.
int strinsert(char **str, char c, int n, int q)
{
int len = my_strlen(*str);
char ins[q + 1];
char *new = malloc(len + q + 1);
memset(ins, c, q);
memset(new, 0, len + q);
ins[q] = '\0';
strncpy(new, *str, n);
new[n] = '\0';
strcat(new, ins);
strcat(new, *str + n);
return (0);
}
strinsert(&str, 'X', strlen(str) / 2, 5);
// Inserting in string str 5 'X' in the middle of the string
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us