Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool is_prefix(char* str1, char* str2){
- if(str1[0]=='\0'){
- return true;
- }
- if(str1[0]==str2[0]){
- return is_prefix(str1+1,str2+1);
- }
- return false;
- }
- int substring_position(char* str1, char* str2){
- if(is_prefix(str1,str2) == true){
- return 0;
- }
- if(str2[0] != '\0'){
- if(1+substring_position(str1,str2+1)>0){
- return 1+substring_position(str1,str2+1);
- }
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment