#include
<
iostream
>
#include
<
assert.h
>
#include
<
string
>
using
namespace
std;
char
*
myStrstr(
const
char
*
src,
const
char
*
pat)
{
char *p = (char*)src;
char *q = NULL;
char *temp = NULL;
if(!*pat)
return (char*)src;
while(*p)
{
temp = p;
q = (char*)pat;
while(*temp && *q && !(*temp – *q))
{
temp++;
q++;
}
if(!*q)
return p;
p++;
}
return NULL;
}
int
myStrcmp(
const
char
*
src,
const
char
*
pat)
{
int ret = 0;
char *p1 = (char*)src;
char *p2 = (char*)pat;
while(*p2 && !(ret = *p1 – *p2))
{
p1++;
p2++;
}
if(ret < 0)
return –1;
if(ret > 0)
return 1;
return ret;
}
char
*
myStrcpy(
char
*
src,
const
char
*
pat)
{
assert ((NULL != src)&&(NULL != pat));
char* newStr = src;
while((*src++ = *pat++) != ‘\0‘)
{
NULL;
}
return newStr;
}
char
*
myStrcat(
char
*
src,
const
char
*
pat)
{
char *p = src;
while(*p)
{
p++;
}
while(*p++ = *pat++)
{
NULL;
}
return src;
}
/**/
/********************abcdef -> efabcde ***************************/
char
*
MoveStr(
char
*
src,
int
steps)
{
int lenth = strlen(src);
char temp[255];
strcpy(temp, src + lenth – steps);
strcpy(temp + steps, src);
*(temp + lenth) = ‘\0‘;
strcpy(src, temp);
return src;
}
void
main()
{
}
转载于:https://www.cnblogs.com/jackill/archive/2009/06/06/1497791.html
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/110901.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...