Created
April 22, 2017 19:10
-
-
Save ArtyomLazyan/4b76a91eb1eb39bc314ebc2d24032b86 to your computer and use it in GitHub Desktop.
ReverseString
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ********** REVERSE STRING *********** */ | |
#include <iostream> | |
int main() | |
{ | |
char str[] = "Hello world"; | |
int i = 0, j = 0; | |
int size = (int)strlen(str); | |
for (i = 0, j = size - 1; i < j; i++, j--) | |
{ | |
char temp = str[i]; | |
str[i] = str[j]; | |
str[j] = temp; | |
} | |
std::cout << str << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment