Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://vk.com/evgenykravchenko0
- ___ ___ ___
- / /\ ___ / /\ / /\
- / /:/_ /__/\ / /:/_ / /:/_
- / /:/ /\ \ \:\ / /:/ /\ / /:/ /\
- / /:/ /:/_ \ \:\ / /:/_/::\ / /:/ /:/_
- /__/:/ /:/ /\ ___ \__\:\ /__/:/__\/\:\ /__/:/ /:/ /\
- \ \:\/:/ /:/ /__/\ | |:| \ \:\ /~~/:/ \ \:\/:/ /:/
- \ \::/ /:/ \ \:\| |:| \ \:\ /:/ \ \::/ /:/
- \ \:\/:/ \ \:\__|:| \ \:\/:/ \ \:\/:/
- \ \::/ \__\::::/ \ \::/ \ \::/
- \__\/ ~~~~ \__\/ \__\/
- ___
- /__/\ ___ ___
- \ \:\ / /\ / /\
- \ \:\ / /:/ / /:/
- _____\__\:\ /__/::\ /__/::\
- /__/::::::::\ \__\/\:\__ \__\/\:\__
- \ \:\~~\~~\/ \ \:\/\ \ \:\/\
- \ \:\ ~~~ \__\::/ \__\::/
- \ \:\ /__/:/ /__/:/
- \ \:\ \__\/ \__\/
- \__\/
- char *strstr(const char* str, const char* substr )
- {
- const char* p;
- for ( p = str; *p; ++p )
- if ( *p == *substr )
- return (char*)p;
- return 0;
- }
- #include <stdio.h>
- void find_str(char const* str, char const* substr)
- {
- char* pos = strstr(str, substr);
- if(pos)
- {
- printf("found the string '%s' in '%s' at position: %ld\n", substr, str, pos - str);
- }
- else
- {
- printf("the string '%s' was not found in '%s'\n", substr, str);
- }
- }
- int main(void)
- {
- char* str = "H E L L O";
- find_str(str, "H");
- find_str(str, "E");
- find_str(str, "L");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement