*** checkRevStr.cpp 查看字符串是否是回文
#include <iostream> #include <string.h> using namespace std; bool checkRevStr (const char * src) { if (src == NULL) return false; const char * end = src + strlen(src) - 1; while (*src++ == *end--); return (src<end)?(false):(true); } int main() { char a[] = "level"; char b[] = "hanna"; if (checkRevStr(b)) { cout << "yes, it is!" << endl; } else { cout << "No, it is not!" << endl; } return 0; }