Last active
August 29, 2015 14:20
-
-
Save huseyin/0a122006c4fb7136f3b6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
* String Reverse | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
void string_reverse(char*); | |
int main(void) | |
{ | |
char str[100]; | |
printf("word:"); | |
gets(str); | |
printf("-> %s\n", str); | |
string_reverse(str); | |
printf("-> %s\n", str); | |
return EXIT_SUCCESS; | |
} | |
void string_reverse(char* string) | |
{ | |
int i, j = strlen(string) / 2, size = strlen(string) - 1; | |
char temp; | |
for (i=0, size; i < j; i++, size--) | |
{ | |
temp = string[i]; | |
string[i] = string[size]; | |
string[size] = temp; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment