i used a two-way linked list "node" for the code::
#include<stdio.h>
#include<malloc.h>
void insert();
void reverse();
struct node
{
char c;
struct node *next;
struct node *back;
}*start=NULL;
int main()
{
int n,i;
printf("Enter the size of the string to be reversed\n");
scanf("%d",&n);
printf("Now enter the %d character of the string one at a time",n);
for(i=0;i<n;i++)
{
insert();
}
reverse();
return(0);
}
void insert()
{
printf("\nEnter the character:\n");
char w;
scanf("%c",&w);
struct node *tmp;
tmp=malloc(sizeof(struct node));
tmp->c=w;
tmp->next=NULL;
if(start==NULL)
{
tmp->back=NULL;
start=tmp;
}
else
{
struct node *q;
q=start;
while(q->next!=NULL)
{
q=q->next;
}
tmp->back=q;
q->next=tmp;
}
}
void reverse()
{
struct node *p=start;
while(p->next!=NULL)
{
p=p->next;
}
printf("\nThe reversed string is :\n");
while(p->back!=NULL)
{
printf("\t%c",p->c);
p=p->back;
}
}