Deletes characters at the specified position in a string.
/*************************************** * ******************************** All Rights Reserved (C) 2015, Wu Yingqiang. ** File name: DelPosChar. c * File ID: none * Content Abstract: Delete the character at the specified position in the string * Other Description: none * Current version: V1.0 * OPERATOR: Wu Yingqiang * completion date: 20150115 *************************************** * *******************************/# include
# Include
# Include
/*************************************** * ******************************** Function description: delete the character at the specified position in the string * input parameter: str -- string to be operated; pos -- location of the character to be deleted * output parameter: str -- string after the character is deleted * return value:-1 -- failed, 0 -- Success * Other Instructions: no * modified date version number modifier content *********************** **************************************** * ******/int DelPosChar (char * str, int pos) {I F (str = NULL) {return-1;} int len = strlen (str); for (int I = pos; I <len; I ++) {str [I-1] = str [I];} str [len-1] = '\ 0'; return 0 ;} /*************************************** * ******************************** function description: main function * input parameter: none * output parameter: none * return value: none * Other description: no * modified date version number modifier content *********************** ************ * **********************************/Void main () {int ret = 0; char buf [] = "hellokityManGood"; // test string printf ("% s \ n", buf); ret = DelPosChar (buf, 1 ); if (ret! = 0) {return;} printf ("% s \ n", buf); ret = DelPosChar (buf, 2); if (ret! = 0) {return;} printf ("% s \ n", buf); ret = DelPosChar (buf, 3); if (ret! = 0) {return;} printf ("% s \ n", buf); system ("pause ");}