diff --git a/Reversing a String/src/Reversing a String.cpp b/Reversing a String/src/Reversing a String.cpp index 80221cd..6fa460f 100644 --- a/Reversing a String/src/Reversing a String.cpp +++ b/Reversing a String/src/Reversing a String.cpp @@ -10,14 +10,20 @@ using namespace std; int main() { - + + //Entering the string char text[] = "Hello there!"; - + + //calculating the size of text int nChars = sizeof(text)-1; - + + //Assiging the address of text array to a pointer char *pStart = text; - char *pEnd = text + nChars - 1; + //setting the last alphabet adrress to a pointer + char *pEnd = text + nChars - 1; + + //Swapping the string into reverse string while(pStart < pEnd) { char save = *pStart; @@ -28,7 +34,8 @@ int main() { pEnd--; } - cout << text << endl; + //printing reverse string + cout <<"\n"<