#include <stdio.h>
void del_c(char* s, char c) {
char* ss;
while(*s) {
if(*s == c) {
ss = s;
while(*ss) {
*ss = *(ss + 1);
ss++;
}
*ss = '\0';
} else {
s++;
}
}
}
int _strlen(char* s) {
int len = 0;
while(*s++) {
len++;
}
return len;
}
int _strcmp(char* s0, char* s1) {
int len0 = 0, len1 = _strlen(s0);
if(len1 != _strlen(s1)) {
return 0;
} else {
while((*s0) && (*s0++ == *s1++)) {
len0++;
}
if(len0 == len1) {
return 1;
} else {
return 0;
}
}
}
void _strcpy(char* s, char* d) {
while(*s) {
*d++ = *s++;
}
*d = '\0';
}
void _strcpy2(char* s, char* d, int len) {
int i;
for(i = 0; i < len; i++) {
*d++ = *s++;
}
*d = '\0';
}
void del_s(char* fs, char* ss) {
int len = _strlen(ss);
char strtmp[0xff];
char* tmp;
while(*fs) {
// printf("%s\n", fs);
_strcpy2(fs, strtmp, len);
// printf("%s\n", strtmp);
if(_strcmp(ss, strtmp)) {
tmp = fs;
while(*tmp) {
*tmp = *(tmp + len);
tmp++;
}
*tmp = '\0';
} else {
fs++;
}
}
}
int main(void) {
char str[] = "my name# is li zhi qiang my name my nam name nams dd name#";
printf("%s\n", str);
// del_c(str, ' ');
// printf("%s\n", str);
del_s(str, "name#");
printf("\n\n%s\n", str);
}