46 lines
720 B
C++
46 lines
720 B
C++
/*
|
|
Nome: Mario
|
|
Cognome: Montanari
|
|
|
|
strpbrk()
|
|
*/
|
|
|
|
#include <iostream>
|
|
#include <cstring>
|
|
|
|
#define SIZE 100+1
|
|
|
|
using namespace std;
|
|
|
|
char *strpbrk(const char *src, const char *dst);
|
|
|
|
int main(void) {
|
|
char src[SIZE] = "mario.montanari@studenti.itisravenna.it";
|
|
char dst[SIZE] = "aeiou";
|
|
char *ptr;
|
|
|
|
ptr = strpbrk(src, dst);
|
|
|
|
cout << src << endl;
|
|
|
|
if (ptr != nullptr) {
|
|
cout << ptr << endl;
|
|
} else {
|
|
cout << "Character not found!" << endl;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
char *strpbrk(const char *src, const char *dst) {
|
|
while (*src) {
|
|
for (const char *ptr = dst; *ptr != '\0'; ptr++) {
|
|
if (*src == *ptr) {
|
|
return (char*)src;
|
|
}
|
|
}
|
|
src++;
|
|
}
|
|
|
|
return nullptr;
|
|
} |