/* same as twotimes(), except that the string specified by the begin * and end pointers MAY contain a null characters ('\0') */ int twotimes2(const char * begin, const char * end) { unsigned int len = end - begin; if (len % 2 != 0) return 0; for (const char * m = begin + len/2; m != end; ++m, ++begin) if (*begin != *m) return 0; return 1; } /* returns TRUE (non-zero) if and only if the input C-string contains * the same string */ int twotimes(const char * s) { const char * p = s; while (*p != 0) ++p; return twotimes2(s, p); }