Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- #include <Windows.h>
- char reversedString[1024] = {0};
- void printReversedString( char *str )
- {
- char *newWord = new char[1024];
- int chAdded = 1;
- while ( (*str != NULL) && (*str != ' ') )
- {
- *newWord++ = *str++;
- chAdded++;
- }
- *newWord++ = 0;
- for ( int i = 0 ; i < chAdded ; i++ )
- *newWord--;
- if ( *str != NULL )
- {
- *str++;
- printReversedString( str );
- }
- strcat(reversedString, " ");
- strcat(reversedString, newWord);
- }
- void main()
- {
- char *pString = new char[1024];
- printf("Enter Original String: ");
- gets(pString);
- putchar('\n');
- printReversedString( pString );
- printf("The string reversed is:%s", reversedString);
- Sleep(55*1000);
- }
Add Comment
Please, Sign In to add comment