#include <string.h> #include <ctype.h> #include <stdio.h>/* insert function ccode the character to be inserted anystring the inserted string Spos Insert the position into the string */void cinsert (char ccode,char *anystring,int spos);/* Delete the function anystring the deleted string Spos delete the first character */void Cdelete ( Char *anystring,int spos); int main (void) {char p[] = "HelloWorld"; Cinsert (' Y ', p, 6); printf ("Insert character y:p =%s\n toward 6th position", p); Cdelete (P, 6); printf ("Delete the 6th character in a string: P =%s\n", p); return 0;} /* Insert function ccode the character to be inserted anystring the inserted string spos the position of the inserted string */void cinsert (char ccode,char *anystring,int spos) {int p; P=strlen (anystring); /* Length of String */spos=spos<0?0:spos; /* Insert Range */spos=spos>=p?p:spos; for (;p >=spos;p--) anystring[p+1]=anystring[p]; /* Start adding */Anystring[spos]=ccode from the last element of the array; /* Insert the character */}/* delete function anystring the deleted string Spos delete the first few characters */void Cdelete (char *anystring,int spos) {int p; P=strlen (anystring); /* Length of String */if (p>0&&spos>=0&&spos<=p) {while (spos<p) {ANYSTRING[SP OS]=ANYSTRING[SPOS+1]; spos++; } }}
Operation Result:
Character editing technology C language implementation