Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- char *string_in(char *string1, char *string2);
- int main(void){
- char *ptr;
- ptr=string_in("flabbergasted", "berg");
- printf("Pointer value: %c\n", *ptr);
- return 0;
- }
- char *string_in(char *string1, char *string2){
- char *ptr1=string1;
- char *ptr2=string2;
- int i, x;
- for(i=0; i<(int)strlen(string1); i++){
- ptr1++;
- ptr2++;
- if (*ptr1==*ptr2){ //if first letter matches
- for(x=i; x<(int)strlen(string1); x++){ //check other letters
- ptr1++;
- ptr2++;
- if(*ptr1!=*ptr2)
- break;
- }
- }
- }
- return (ptr1+1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement