-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMSG.C
More file actions
100 lines (73 loc) · 1.18 KB
/
MSG.C
File metadata and controls
100 lines (73 loc) · 1.18 KB
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
#include<alloc.h>
#include<stdio.h>
#include<conio.h>
struct node
{
char msg[80];
struct node *link;
};
struct node *getnode()
{
return (struct node*)malloc( sizeof(struct node ) );
}
struct node * addMsg( struct node *);
void displayMsg( struct node *);
void main( )
{
int ch;
struct node *H;
H = NULL;
while( 1 )
{
clrscr();
printf("1. Add message\n");
printf("2. Display message \n");
scanf("%d", &ch);
switch( ch )
{
case 1:
H = addMsg( H );
break;
case 2:
displayMsg( H );
break;
default:
return;
}
getch();
}
}
struct node * addMsg( struct node *H)
{
struct node *T , *N;
fflush(stdin);
printf("Enter message \n");
N = getnode( );
gets( N->msg );
if( H == NULL )
{
H = N;
H->link = H;
}
else
{
T = H;
while( T->link != H )
T = T->link;
T->link = N;
N->link = H;
}
return H;
}
void displayMsg( struct node *T)
{
_setcursortype( _NOCURSOR );
while( !kbhit() )
{
clrscr();
gotoxy( 20 , 23 ); // x = 20 , y=23
printf("%s", T->msg);
T = T->link;
sleep(3);
}
}