fork download
  1. #include <stdio.h>
  2.  
  3. const char chars[] = {'a', 'b', 'c', 'd', 'e', 'f'};
  4.  
  5. template<class T>
  6. bool memberOf(T x, const T elems[])
  7. {
  8. printf("sizeof(elems) == %d\n", sizeof(elems));
  9. for(int i = 0;i < sizeof(elems); ++i) {
  10. if (x == elems[i])
  11. return true;
  12. }
  13. return false;
  14. }
  15.  
  16. int main(int argc, char* argv[])
  17. {
  18. if (memberOf('f', chars)) {
  19. printf("found!!\n");
  20. } else {
  21. printf("not found.\n");
  22. }
  23. }
Success #stdin #stdout 0s 2884KB
stdin
Standard input is empty
stdout
sizeof(elems) == 4
not found.