So simple,just for ex.
- #include <stdio.h>
- char *find_char(char const *source,char const *chars);
- int main(void){
- char *source="hellopnig0s";
- char *chars="epg0";
- char *result;
- result=find_char(source,chars);
- if(result){
- printf("We found %c in position:%p\n",*result,result);
- }else{
- puts("Nothing be found.");
- }
- }
- char *find_char(char const *source,char const *chars){
- char * check;
- while(*chars!='\0'){
- while(*source!='\0'){
- if(*source++==*chars){
- return source-1;
- break;
- }else{
- check=NULL;
- }
- }
- chars++;
- }
- if(!check){
- return check;
- }
- }
本文转hackfreer51CTO博客,原文链接:http://blog.51cto.com/pnig0s1992/440878,如需转载请自行联系原作者