Reverse a String without using strrev in C

C Program to reverse a string without using strrev() function

Source code :

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

int main(){
    
    char original[] = "LOVE";
    int length = strlen(original);
    
    char reversed[length];
    int i,j=0;
    
    for( i = length - 1 ; i >= 0 ; i-- ){
        reversed[i] = original[j];
        j++;
    }
    
    printf("Original String : %s",original);
    printf("\nReversed String : %s",reversed);

    return 0;

}

Output :

Original String : LOVE
Reversed String : EVOL

Output :


                

Comments :