I found this program for reversing this program online.
I have just started learning C.
I am not able to understand few things here.
- Why while is ended with ;
- what does
while(str[++i]!='\0');
mean? - Is
rev[j++] = str[--i];
same as writing j++; and i--; inside the while loop?
This is the program:
#include<stdio.h>
int main(){
char str[50];
char rev[50];
int i=-1,j=0;
printf("Enter any string : ");
scanf("%s",str);
while(str[++i]!='\0');
while(i>=0)
rev[j++] = str[--i];
rev[j]='\0';
printf("Reverse of string is : %s",rev);
return 0;
}