目录
1.字符串正反序连接
void fun (char *s, char *t)
{
int i,j;
while(t[i] = s[i])i++;
j = i;
while(i-->=0)
{
t[j++] = s[i];
}
t[j] = '\0';
}
2.复制部分字符串
void strcopy(char *str1,char *str2,int m)
{
int i;
int j = 0;
for(i=m-1;str1[i]!='\0';i++,j++)
{
str2[j] = str1[i];
}
}
3.删除字符串中数字字符
void delnum(char *s)
{
int i = 0;
int j = 0;
while(s[i]!='\0')
{
if(!(s[i]>='0'&&s[i]<='9'))
s[j++] = s[i];
i++;
}
s[j] = '\0';
}
*4.查找子串
char *search(char *s, char *t) {
int i = 0;
while (s[i] != '\0') {
if (s[i] == t[0]) {
int j = 1;
while (s[i + j] == t[j] && t[j] != '\0') {
j++;
}
if (t[j] == '\0') {
return s + i;
}
}
i++;
}
return NULL;
}