Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- char *search(char *string, char *ch);
- int main(void){
- char *ptr=search("somehow it's shifted", 'z');
- printf("boop %c\n", *ptr);
- return 0;
- }
- char *search(char *string, char *ch){
- char *ptr=string;
- unsigned long length=strlen(string);
- printf("%lu\n", length);
- unsigned long count=0;
- while (*ptr!=ch){
- ptr++;
- count++;
- if (count==length){
- printf("Character not found in string.\n");
- break;
- }
- }
- return (ptr);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement