/* * C and pointer. Chapter 6: The second question deletes a part of a string, for example, abcdefg. If fgh, CDF, and xabc are input, the deletion fails. If CDE is input, the deletion is successful, get the abfg deletion function prototype: int del_substr (char * stre, char const * substr) stre is the source string to be operated, and substr is the substring to be deleted. */ # Include <Stdio. h> # Include <Stdlib. h> Int Del_substr ( Char * Stre, Char Const * Substr ){ Char * STR = Stre; Char * Source = STR; Char String = * Source; Char Const * Sub_str; While ( String ! = ' \ 0 ' ) {Sub_str = Substr; While (* Sub_str! = ' \ 0 ' && String ! = ' \ 0 ' & * Sub_str = String ) {Sub_str ++ ; String = * ++ Source ;} If (* Sub_str =' \ 0 ' ){ // Matched !! While (* Source! = ' \ 0 ' ){ * STR ++ = * Source ++ ;} While (* Str! = ' \ 0 ' ){ * STR ++ = ' \ 0 ' ;} Return 1 ;} Str ++ ; Source = STR; String = * Source ;} Return 0 ;} Int Main (){ Char Source [ 100 ]; Char * SRC; Char Chars [ 100 ]; Printf ( " Enter a source string: \ n " ); Gets (source ); While (1 ) {SRC = & Source; printf ( " Enter a string to be deleted: \ n " ); Gets (chars ); Int Flag = Del_substr (SRC, chars ); If (Flag = 0 ) {Printf ( " An error occurred while deleting the matched items !! No matching string found !! \ N " ); Continue ;} Printf ( " Matched and deleted !! : \ N " ); Printf ( " % C " ,* Source ); While (* ++ SRC! = ' \ 0 ' ) Printf ( " % C " ,* SRC); printf ( " \ N " ); Break ;} Return 0 ;}