-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathurlmiddlelevelme.c
118 lines (101 loc) · 1.58 KB
/
urlmiddlelevelme.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include<stdio.h>
#include<string.h>
#define MAX 50
int ftop=-1,btop=-1;
char fstack[MAX][20];
char bstack[MAX][20];
void forward()
{
if(isemptyb())
{
printf("Enter URL: ");
scanf("%s",&fstack[++ftop]);
}
else
{
fstack[++ftop][20]=bstack[btop--][20];
printf("Curernt url is : %s",fstack[ftop]);
}
}
void back()
{
bstack[++btop][20]=fstack[ftop--][20];
printf("Current URL is: %s",fstack[ftop]);
}
void fdisplay()
{
if(isemptyf())
printf("\nOOps!! No URL ahead!!\n\n");
else
{
int i;
for(i=0;i<=ftop;i++)
printf("%s",fstack[ftop]);
}
}
void bdisplay()
{
if(isemptyb())
printf("\nOOps!! No URL Back!!\n\n");
else
{
int i;
for(i=0;i<=btop;i++)
printf("%s",bstack[btop]);
}
}
int isemptyf()
{
if(ftop==-1)
return 1;
else
return 0;
}
int isemptyb()
{
if(btop==-1)
return 1;
else
return 0;
}
void main()
{
int j=0,ch=1;
while(ch!=12)
{
if(j==0)
{
printf("\nEnter URL: ");
scanf("%s",fstack[++ftop]);
j=1;
printf("\n\nYou can't move Back. Move forward.\n\n");
}
else
{
printf("\n\n1.Forward\n");
printf("2.Back\n");
printf("3.Display Forward Urls\n");
printf("4.Display Backward Urls\n");
printf("5.Close\n");
printf("\nEnter your choice: ",&ch);
scanf("%d",&ch);
switch(ch)
{
case 1:
forward();
break;
case 2:
back();
break;
case 3:
fdisplay();
break;
case 4:
bdisplay();
break;
case 5:
exit(1);
}
}
}
}