Search char in an exat string with pointer
2010-12-04 11:18
316 查看
So simple,just for ex.
本文出自 “About:Blank H4cking” 博客,请务必保留此出处http://pnig0s1992.blog.51cto.com/393390/440878
#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; } }
本文出自 “About:Blank H4cking” 博客,请务必保留此出处http://pnig0s1992.blog.51cto.com/393390/440878
相关文章推荐
- Search String in a String array with empty string
- CH1-3: remove duplicate char in a string, with/without additional buffer
- Search for a string in an infinite stream of input string.
- Deal with replacing a string in an NTEXT field
- JS. How to replace html element with another element/text, represented in string?
- iOS- Please sign in with an app-specific password. You can create one at applied.apple.com.
- C语言中指针, 数组和字符串(Pointer, Array and String in C Programming Language)
- 上传到苹果市场是xcode提示:Cannot proceed with delivery: an existing transporter instance is currently uploadin
- 【5】Replace all spaces in a string with ‘%20’
- Bug: Application called a GL11 Pointer method with an indirect Buffer
- Create an avatar and chat with your friends in rooms you design
- There is no getter for property named 'column' in 'class java.lang.String'] with root cause
- Unity5 使用自带的字体导致BuildAssetbundle失败An asset is marked with HideFlags.DontSave but is included in the
- The operation couldn’t be completed. Unable to log in with account ''. An unexpected failure occurre
- Tricks in decide the index in the binary search with duplicate elements
- ANR in an IntentService with its own process
- There's an iterator stored in with each hash
- String.With in Suteki .Shop
- Write a function to convert an IPv4 Address in string format to an unsigned integer
- Find the longest substring with k unique distinct characters in a given string (Google)