Write the following function without using the C++ string class or any functions in the standard library, including strlen(). You may use pointers, pointer arithmetic or array notation.
Write the function first Of Any(). The function has two parameters (str1, str2), both pointers to the first character in a C-style string. You should be able to use literals for each argument. The function searches through str1, trying to find a match for the first character inside str1 that does NOT appear inside str2. Return the index of the first character in str1 that does not appear inside str2. Note that if all of the characters in str1 appear in str2, then return the length of the C-String s1. (This will happen automatically if you write function correctly.)

Answer :

kendrich

Answer:

See explaination

Explanation:

#include<iostream>

using namespace std;

const char* firstOfAny(const char *str1,const char *str2){

const char *p=str1;

while((*p)!='\0'){

const char *q=str2;

while((*q)!='\0'){

if((*p)==(*q)){return p;}

q++;

}

p++;

}

return p;

}

int main(){

cout<<firstOfAny("ZZZZuker","aeiou");

cout<<endl;

cout<<firstOfAny("ZZZzyx","aeiou");

return 0;

}

Other Questions