Moon Light Box

Time is Money

C - Reverse String

| Comments

#include <stdio.h>
#include <string.h>

void reverse(char* str)
{
    int i, j;
    char c;
    for(i = 0, j = strlen(str)-1; i<j; ++i, --j)
        c = str[i], str[i] = str[j], str[j] = c;
}

int main()
{
    char str[] = "ABCDE";
    reverse(str);
    puts(str);
    return 0;
}

Comments

comments powered by Disqus