#include <stdio.h>
#include <string.h>
char reverse(char *s, char *t);
int main()
{
char source[25]; /* source string */
char target[25]; /* Target string */
printf("Enter the source string\n");
scanf("%s", source);
reverse(source, target); /* function which passes the base address of source and target */
printf("The target string is %s", target);
getch();
}
char reverse(char *s, char *t) /* Pointers to source and target */
{
int length=0;
length=strlen(s)-1; /* The length of the source string is calculated and then assigned to length */
printf("Length is %d\n", length);
printf("%s", s);
while(length>=0)
{
*t=*(s+length); /* the last charachter s[length] or *(s+length) is copied to the target */
printf("%d\n", *(s+length));
t++; /* The pointer is made to point to the next memory address of the target */
length--; /* length is reduced so the the next charachter is s[length-1] */
}
*t='\0'; /* The terminating charchter is assigned to the end of the target */
}