Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Couting number of substring occurances in C++
#include<iostream> #include<string> #include<algorithm> using namespace std; int countFreq(string str, string str_to_search) { int count = 0, nPos = str.find(str_to_search, 0); // fist occurrence while (nPos != string::npos) { count++; nPos = str.find(str_to_search, nPos + 1); } cout << count; } int main() { int chars; cin >> chars; string filename, finder; cin >> filename >> finder; countFreq(filename, finder); return 0; }
run
|
edit
|
history
|
help
0
Vector impl
Deque RotateString
Why C++ optimizer has problems with these temporary variables
NWD, algorytm Euklidesa
ExceptionHandling2
Finding Ocean
Test 11(2020)
My love
Gauss v0.1
Wipro Problem 1