initial
This commit is contained in:
24
charP.cpp
Normal file
24
charP.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int countX (const char *p, const char *x) {
|
||||
if (p==nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
|
||||
for (; *p != 0; p++) {
|
||||
if (*p == *x) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int main (void) {
|
||||
cout << countX("Haaay, Koray", "a") << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user