Dear all,
I am trying to do a program using gcc compiler to reverse a string input.
I am stuck at the for loop which I think there is some mistake there. I only manage to reverse two of the letters only.
Kindly advise.
Below is part of my code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define size 128
int main(void)
{
char line[size];
printf("Enter line:");
fgets(line, size, stdin);
int n, i;
n = strlen(line);
for (i = 0; i > n; ++i)
{
line[i] = line[n-1-i];
}
printf("Your reverse line is %s\n, line);
exit(0);
}
Would really appreciate someone to point out where I have gone wrong.
Thanks.