//*************************************************************// //** 函数名称: // //** 函数功能:字符串的连接 // //** 作 者: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; }
|
|