fork download
  1. #include <iostream>
  2.  
  3. template<int length>
  4. bool compare(const char *begin, const char *str){
  5. int i = 0;
  6. while(i != length && *begin == *str){
  7. i++;
  8. begin++;
  9. str++;
  10. }
  11. return i == length;
  12. };
  13.  
  14. int main()
  15. {
  16. std::cout << compare<4>("<!--", "<!--") << std::endl;
  17. }
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
1