Hi,
what anduril was reffering to is to use the standard string.h functions of the clib, like:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char * str_insert(char * insert, char * src, size_t offset)
{
char * temp;
if ((temp = malloc(strlen(src) + strlen(insert) + 1)) != NULL) {
strncpy(temp, src, offset);
strcat(temp, insert);
strcat(temp, &src[offset]);
}
return temp;
}
int main(int argc, char ** argv)
{
char * newstr;
int offset;
if (argc < 4) {
printf("Missing parameters.\n");
printf("Syntax: %s <string> <string_to_insert> <offset>\n", argv[0]);
} else {
offset = (int) strtol(argv[3], NULL, 10);
if ( (newstr = str_insert(argv[2], argv[1], offset)) != NULL ) {
printf("The new string is: %s\n", newstr);
}
}
return 0;
}
which gives output like this:
Code:
me@Sirius:/data/secure/source/cprogs$ ./strins_ex abcdef xyz 1
The new string is: axyzbcdef
me@Sirius:/data/secure/source/cprogs$ ./strins_ex abcdef xyz 4
The new string is: abcdxyzef
me@Sirius:/data/secure/source/cprogs$ ./strins_ex abcdef xyz 10
The new string is: abcdefxyz
here is a link to https://gnu.org/software/libc/manual...mono/libc.html
the standard gnu c library.
Cheers,