Reverse String
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
/*************************************************************************
> File Name: LeetCode344.c
> Author: Juntaran
> Mail: Jacinthmail@gmail.com
> Created Time: 2016年05月10日 星期二 02时25分37秒
************************************************************************/ /************************************************************************* Reverse String Write a function that takes a string as input and returns the string reversed. Example:
Given s = "hello", return "olleh". ************************************************************************/ #include "stdio.h" char* reverseString(char* s)
{
int i;
int length = strlen(s);
char temp; for( i=; i<length/; i++ )
{
temp = s[i];
s[i] = s[length-i-];
s[length-i-] = temp;
}
return s;
} int main()
{
char* s = "hello";
reverseString(s);
return ;
}