#include<stdio.h>
#include<conio.h>
#include<string.h>
#define max 30
void push(char ch);
char pop();
char stack[max];
int top=-1;
void main()
{
char a[20],b[20],k[40],ch;
int i,l1,l2;
clrscr();
printf("\n Enter First String:-\n");
scanf("%s",a);
printf("\n Enter Second String:-\n");
scanf("%s",b);
l1=strlen(a);
l2=strlen(b);
for(i=0;i<l2;i++)
{
push(b[i]); //push second string into stack
}
push(' ');
for(i=0;i<l1;i++)
{
push(a[i]); //push first string into stack
}
printf("\n After concatenation of two string:-\n");
i=0;
while(top!=-1)
{
ch=pop();
if(ch==' ')
{
k[i]='\0';
printf("%s",strrev(k));
i=0;
}
else
{
k[i]=ch;
i++;
}
}
k[i]='\0';
printf("%s",strrev(k));
getch();
}
void push(char ch)
{
if(top==max-1)
{
printf("\n Stack is full");
}
else
{
top++;
stack[top]=ch;
}
}
char pop()
{
char t;
if(top==-1)
{
printf("\n Stack is Empty");
}
else
{
t=stack[top];
top--;
return(t);
}
}
#include<conio.h>
#include<string.h>
#define max 30
void push(char ch);
char pop();
char stack[max];
int top=-1;
void main()
{
char a[20],b[20],k[40],ch;
int i,l1,l2;
clrscr();
printf("\n Enter First String:-\n");
scanf("%s",a);
printf("\n Enter Second String:-\n");
scanf("%s",b);
l1=strlen(a);
l2=strlen(b);
for(i=0;i<l2;i++)
{
push(b[i]); //push second string into stack
}
push(' ');
for(i=0;i<l1;i++)
{
push(a[i]); //push first string into stack
}
printf("\n After concatenation of two string:-\n");
i=0;
while(top!=-1)
{
ch=pop();
if(ch==' ')
{
k[i]='\0';
printf("%s",strrev(k));
i=0;
}
else
{
k[i]=ch;
i++;
}
}
k[i]='\0';
printf("%s",strrev(k));
getch();
}
void push(char ch)
{
if(top==max-1)
{
printf("\n Stack is full");
}
else
{
top++;
stack[top]=ch;
}
}
char pop()
{
char t;
if(top==-1)
{
printf("\n Stack is Empty");
}
else
{
t=stack[top];
top--;
return(t);
}
}