fork(3) download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <cstring>
  4.  
  5. int func(int* arr, int length, int number){return std::find(arr,arr+length,number)-arr;}
  6. int func(char* str, char ch){return std::find(str,str+std::strlen(str),ch)-str;}
  7.  
  8. int main() {
  9. int arr[] {1,2,3};
  10. std::cout<<func(arr,3,2)<<std::endl;
  11. std::cout<<func("ABCDE",'E')<<std::endl;
  12. }
Success #stdin #stdout 0s 4284KB
stdin
Standard input is empty
stdout
1
4