fork(3) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6. string inputs[2] = {"stack overflow", "stack exchange"};
  7. string search_key = "stack";
  8. int count;
  9. for(int i = 0; i <sizeof(inputs)/sizeof(inputs[0]); i++)
  10. {
  11. if (inputs[i].find(search_key) != string::npos)
  12. count++;
  13. }
  14.  
  15. cout << count;
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
2