分享

字符串查找

 烧包谷free 2013-09-13

//*************************************************************//
//**  函数名称:                                               //
//**  函数功能:字符串的连接                                   //
//**  作    者:xt                                             //
//**  时    间:2013/8/5                                       //
//*************************************************************//
#include "stdio.h"
#include "string.h"

void  main()
{
int search_str(char s[], char ch);

char s[80],ch;
int pos;

printf("Input the Sring:");
gets(s);
printf("Input the needed word:");
ch=getchar();

pos=search_str(s,ch);
if(pos==-1)
printf("Not found the word~!");
else
printf("found the word:%d",pos);



}


int search_str(char s[], char ch)
{
int i;
for(i=0;s[i]!='\0';i++)
if(s[i]==ch)
return i;
return -1;
}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多