I'm getting a blank output in my console screen when I try to print the string value in a reverse order. If I use for loop for printing the String value is printing, but when I simply print using %s, it is not printing? Why?
#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
char name1[10],name2[10];
int i,len,j;
clrscr();
printf("\nEnter the string that u want to get reversed:");
scanf("%s",&name1);
for(i=0;name1[i]!='\0';i++);
len=i;
j=i;
for(i=0;i<=len;i++)
{
name2[i]=name1[j];
j--;
}
printf("\nThe reversed string is:");
printf("%s",name2);
getch();
}