fork(2) download
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5.  
  6. template<size_t N>
  7. constexpr size_t strlen_(const char (&data)[N]) noexcept{
  8. return N - 1;
  9. }
  10.  
  11. int main()
  12. {
  13. const char hello_world[] = {'a','b','\0','e','f'};
  14. cout << strlen_(hello_world) << endl; // Wrong. Even if the zero was not there.
  15. cout << strlen(hello_world) << endl;
  16.  
  17. // your code goes here
  18. return 0;
  19. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
4
2