Reverse a String in C++

Source code :

#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int i=0,len;
char str[20]="tnailora";
char rev[20];
len=strlen(str);
while(len>=0)
{
rev[i]=str[len];
len--;
std::cout<<rev[i];
i++;
}
return 0;
}

Output :

0

Output :


                

Comments :