char *strchrTest(char * ptr,char c);

Action()
{
char str[]={"thisisadog"};
char c='s';
lr_output_message("%s",strchrTest(str,c));

return 0;
}
char *strchrTest(char *ptr,char c)
{
char *p=ptr;
char *p1=ptr;

if(ptr!=NULL)
{
//移动指针到字符串尾
while(*ptr!='\0')
{
ptr++;
}

//逆向查找指定字符
while(ptr!=p1)
{
if(*ptr==c)
{
p=ptr;
break;
}
ptr--;
}
}

//实现大写到小写的转化;
if((*p>='A')&&(*p<='Z'))
{
}
else if ((*p>='a')&&(*p<='z'))
{
*p=*p-32;

}else
{
lr_output_message("%c不是字母",c);
}

//lr_output_message("%s",ptr);

return p;
}

posted on 2018-06-17 12:28  新美好时代  阅读(266)  评论(0编辑  收藏  举报