Character editing technology C language implementation

Source: Internet
Author: User

#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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.