字符串逆序

#include <iostream> using namespace std; typedef int BOOL; #define FALSE 0 #define TRUE 1 BOOL ResvStr(char* pszStr); int main() { char szTemp[300] = "/0"; cout << "please input string: "; cin.getline(szTemp, 300 - 1); ResvStr(szTemp); cout << "after reserve: " << endl; cout << szTemp << endl; return 0; } BOOL ResvStr(char* pszStr) { int i = 0; int nRun = 0; int nLen = 0; char chTemp = '/0'; if (NULL == pszStr) { return FALSE; } nLen = strlen(pszStr); nRun = nLen / 2; for (i = 0; i < nRun; i++) { chTemp = pszStr[i]; pszStr[i] = pszStr[nLen - i - 1]; pszStr[nLen - i - 1] = chTemp; } return TRUE; } 

你可能感兴趣的:(String,null,input,include)