2 Software and Hardware Requirements 3 Technical Details

Download as pdf or txt
Download as pdf or txt
You are on page 1of 40

Table of Contents

1 INTRODUCTION............................................................................................................ 1

2 SOFTWARE AND HARDWARE REQUIREMENTS .................................................... 2

3 TECHNICAL DETAILS ..................................................................................................... 3

3.1 Stack................................................................................................................................... 4

3.2 Queue ................................................................................................................................. 5

3.3 Doubly linked list ............................................................................................................... 6

3.3.1 Structure in c .............................................................................................................. 6

3.4 Modules.............................................................................................................................. 7

3.4.1 Admin panel ............................................................................................................... 7

3.4.2 Signup ........................................................................................................................ 7

3.4.3 Login .......................................................................................................................... 7

3.4.4 Leave .......................................................................................................................... 7

3.4.5 Exit ............................................................................................................................. 7

3.5 Implementation in c language ............................................................................................ 8

4 RESULTS ........................................................................................................................... 27

5 CONCLUSION .................................................................................................................. 36

6 BIBILOGRAPHY .............................................................................................................. 37

iii
LIST OF FIGURES

Figure 1 Stack data structure .................................................................................... 4

Figure 2 Queue data structure ................................................................................... 5

Figure 3 Doubly linked list data structure ................................................................ 6

Figure 4 Main page of application .......................................................................... 27

Figure 5 User-1 Signup ........................................................................................... 28

Figure 6 User-2 Signup .......................................................................................... 29

Figure 7 User-1 Login............................................................................................. 30

Figure 8 User-2 Login............................................................................................. 31

Figure 9 Message sending by user-1 ...................................................................... 32

Figure 10 Message seen by user-2 .......................................................................... 33

Figure 11 Admin page ............................................................................................ 34

Figure 12 View all records by admin ..................................................................... 35

iv
CHAPTER-1

1 INTRODUCTION

This project is an Application of Data Structures to build a terminal based


messenger system in C. In this system the user has to login using a username and
password, then the user can send and receive messages. They can know whether
the message is received are not and also can know the contact details. This system
makes use of data structures like stack queues and doubly link lists.

Real time chat is virtually any online communication that provides a real
time or live transmission of text messages from sender to receiver. It’s
lightweight to use the terminal for our chat, as there is no opening of the
browser, loading of JS libraries or any frontend code. Also, it allows us to
quickly test our ideas without worrying about what the user interface would
look like.

The basic functions being performed by our system are :

1) Admin panel :-
Admin has the authority to search and view the record of all the users.
2) Users :-
User has to sign in with his name and mobile number then user will be
allotted so that user can send to others and receive messages from others.

1
CHAPTER-2

2 SOFTWARE AND HARDWARE REQUIREMENTS

2.1 SOFTWARE REQUIREMENTS

• Operating System : Windows 2000/ xp /7

• Front-End : Turbo c

• Back-end : Ms access 2007

2.2 HARDWARE REQUIREMENTS

• PROCESSOR : Pentium IV processor or Greater

• RAM : 128 Mega Byte (MB) or Greater

• HARDDISK : 1.2 Giga Byte (GB) or Greater

• Keyboard , Mouse, Monitor &Printer.

2
CHAPTER-3

3 TECHNICAL DETAILS

C is a general-purpose, high-level language that was originally developed


by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C
was originally first implemented on the DEC PDP-11 computer in 1972. In
1978, Brian Kernighan and Dennis Ritchie produced the first publicly available
description of C, now known as the K&R standard. The UNIX operating
system, the C compiler, and essentially all UNIX application programs have
been written in C. C has now become a widely used professional language for
various reasons:

• Easy to learn

• Structured language

• It produces efficient programs

• It can handle low-level activities

• It can be compiled on a variety of computer platforms

C is a powerful general-purpose programming language. It is fast, portable and


available in all platforms.

3
In this application we are using stack, queues and doubly linked list.

3.1 Stack

Stack is a linear data structure which follows a particular order in which


the operations are performed. The order may be LIFO(Last In First Out) or
FILO(First In Last Out).

Figure 1 Stack data structure

Two operations are used:

I. Push :
Adds an item in the stack. If the stack is full, then it is said to be an
Overflow condition.
II. Pop :
Removes an item from the stack. The items are popped in the
reversed order in which they are pushed. If the stack is empty, then
it is said to be an Underflow condition.

4
3.2 Queue

Queue is an abstract data structure, somewhat similar to Stacks. Unlike


stacks, a queue is open at both its ends. One end is always used to insert data
(enqueue) and the other is used to remove data (dequeue). Queue follows First
In-First-Out methodology, i.e., the data item stored first will be accessed first.

Figure 2 Queue data structure

• Elements is inserted from one end called REAR and deleted from the other end
called as FRONT.
• Front points to the beginning of the queue and Rear points to the end of the
queue.
• Queue follows the FIFO (First - In - First Out) structure.
• According to its FIFO structure, element inserted first will also be removed first.
• In a queue, one end is always used to insert data (enqueue) and the other is used
to delete data (dequeue), because queue is open at both its ends.
• The enqueue() and dequeue() are two important functions used in a queue.

5
3.3 Doubly linked list

Doubly linked list is a complex type of linked list in which a node


contains a pointer to the previous as well as the next node in the sequence.
Therefore, in a doubly linked list, a node consists of three parts: node data,
pointer to the next node in sequence (next pointer) , pointer to the previous
node (previous pointer).

Figure 3 Doubly linked list data structure

3.3.1 Structure in c

In C, structure of a node in doubly linked list can be

struct node
{
struct node *prev;
int data;
struct node *next;
}

6
3.4 Modules

In this application we are having five modules. Different modules perform


different functionality.

3.4.1 Admin panel

Admin has the authority to search and view the record of all the users. In
record every user name and phone number with his/her status weather
allotted or not .

3.4.2 Signup

Users can signup with their details like username and phone number. So
that user can be able to login and to communicate with other users who are a
member of this application.

3.4.3 Login

Users are signed up with their credentials. Then user can login with their
credentials and can use this application easily. They can communicate with
other user’s using this application which is terminal based application.

3.4.4 Leave

Users can leave this application if they are having trouble or not interested
in this application.

3.4.5 Exit

Users or admin using this terminal based application. After the usage they
can come out terminal by choosing the Exit option in the application. So the
terminal will be closed.

7
3.5 Implementation in c language

#include<stdio.h>

#include<stdlib.h>

#include<malloc.h>

#include<string.h>

void startup();

struct no{

struct no *ne;

char name[30],mob[30];

};//for stack ,is with each and every person

struct nod{

struct nod *nex;

char name[30],mob[30],msg[30];

};//for Queue , is with each and every person

struct node{

struct nod *f,*r;

struct no *top;

struct node *next,*prev;

int codeid;

char name[30],mob[30],status[30];

8
};//for doubly linked lists --->the main Database

struct node *start = NULL;

void viewAllRec(){

struct node *ptr;

printf("\n");

ptr=start;

if(ptr==NULL){

printf("\nNo records found :(\n");

else{

while(ptr!=NULL){

printf(" # [ codeid = %d ,name = %s , Mob. = %s , status =


%s ] #\n",ptr->codeid,ptr->name,ptr->mob,ptr->status);

ptr=ptr->next;

void searchRec(){

struct node *ptr;

int flag=0;

9
char mob[30];

printf("\nEnter Mobile number to be searched : ");

scanf("%s",mob);

ptr=start;

while(ptr!=NULL){

if(strcmp(ptr->mob,mob)==0){

printf("\nRecord Found :) !!!\nThe details are :\n");

printf(" # [ codeid = %d , name = %s , Mob. = %s , status =


%s ] #\n",ptr->codeid,ptr->name,ptr->mob,ptr->status);

ptr=ptr->next;

flag=1;

break;

ptr=ptr->next;

if(flag==0){

printf("\nRecord not found :( \n");

void leave(){

10
char mob[30];

struct node *ptr;

printf("Enter Your Mobile Number : ");

scanf("%s",mob);

ptr=start;

while(ptr!=NULL){

if(strcmp(ptr->mob,mob)==0){

printf("\nRecord Found.\nRecord deleted successfully.\n");

strcpy(ptr->name,"0");

strcpy(ptr->mob,"0");

strcpy(ptr->status,"unallocated");

strcpy(ptr->name,"0");

ptr->f=ptr->r=NULL;ptr->top=NULL;

ptr=ptr->next;

void push(char recMob[],char name[],char mob[]){

struct no *nn;

struct node *ptr;

11
nn=(struct no*)malloc(sizeof(struct no));

strcpy(nn->name,name);

strcpy(nn->mob,mob);

nn->ne=NULL;

ptr=start;

while(ptr!=NULL){

if(strcmp(ptr->mob,recMob)==0){

if(ptr->top==NULL){

nn->ne=NULL;

ptr->top=nn;

else{

nn->ne=ptr->top;

ptr->top=nn;

ptr=ptr->next;

}//for stack

12
void pop(char mob[]){

struct node *ptr;

struct no *temp;

int flag=0;

ptr=start;

while(ptr!=NULL){

if(strcmp(ptr->mob,mob)==0){

if(ptr->top==NULL){

printf("\nNo recent Contacts left to be viewed . . .");

flag=1;

else{

printf(" # [ name = %s , mob = %s ] # \n",ptr->top-


>name,ptr->top->mob);

temp=ptr->top;

ptr->top=ptr->top->ne;

free(temp);

if(flag==0){

13
pop(mob);

else if(flag==1){

break;

ptr=ptr->next;

}//for stack

void enqueue(char recMob[],char msg[],char name[],char mob[]){

struct nod *nn;

struct node *ptr;

nn=(struct nod*)malloc(sizeof(struct nod));

//printf("%s %s %s %s",recMob,msg,name,mob);

strcpy(nn->name,name);

strcpy(nn->mob,mob);

strcpy(nn->msg,msg);

nn->nex=NULL;

ptr=start;

while(ptr!=NULL){

14
if(strcmp(ptr->mob,recMob)==0){

if(ptr->f==NULL){

ptr->f=ptr->r=nn;

ptr->r->nex=ptr->f->nex=NULL;

else{

ptr->r->nex=nn;

ptr->r=nn;

ptr->r->nex=NULL;

ptr=ptr->next;

}//for queue

void dequeue(char mob[]){

struct node *ptr;

int flag=0;

struct nod *temp;

ptr=start;

15
while(ptr!=NULL){

if(strcmp(ptr->mob,mob)==0){

if(ptr->f==NULL){

printf("\nNo recent messages left to be viewed . . .");

flag=1;

else{

printf(" # [ name = %s , mob = %s , msg = %s ] #


\n",ptr->f->name,ptr->f->mob,ptr->f->msg);

temp=ptr->f;

ptr->f=ptr->f->nex;

free(temp);

if(flag==0){

dequeue(mob);

else if(flag==1){

break;

16
}

ptr=ptr->next;

}//for queue

void login(){

int flag=0;int opt;

struct node *ptr,*ptr1;

char name[30],mob[30],recName[30];

char recMob[30],msg[30];

printf("\n< Hint: username is name while signup and password is mobile


number >\n");

printf("\nEnter username : ");

scanf("%s",name);

printf("\nEnter password : ");

scanf("%s",mob);

ptr=start;

while(ptr!=NULL){

if(strcmp(ptr->name,name)==0&&strcmp(ptr->mob,mob)==0){

flag=1;

while(1){

17
printf("\nEnter your choice:\n1.Send a Message\n2.View All
Recieved Msg\n3.view Recent contacts\n4.Logout\n");

scanf("%d",&opt);

switch(opt){

case 1:

printf("\nWhom do you want to


send message ? ... enter mobile number : ");

scanf("%s",recMob);

printf("\nEnter Message\n");

scanf("%s",msg);

enqueue(recMob,msg,name,mob);//enqueue in recievers queue ur name ,


mob , msg

ptr1=start;

while(ptr1!=NULL){

if(strcmp(ptr1-
>mob,recMob)==0){

strcpy(recName,ptr1-
>name);

18
strcpy(recMob,ptr1-
>mob);

ptr1=ptr1->next;

//printf("%s %s %s %s %s
",recMob,msg,name,mob,recName);

push(mob,recName,recMob);//in ur
stack push recevers name , mob

push(recMob,name,mob);//in
recievers stack push ur name , mob

break;

case 2:

//printf("%s",mob);///////////////////////////////////////////////////////////////////////////

dequeue(mob);//dequeue my queue
completely

break;

case 3:

//printf("%s",mob);///////////////////////////////////////////////////////////////////////////

19
pop(mob);//pop my stack
completely

break;

case 4:

startup();

break;

default:

printf("\nWrong choice
pressed\n");

break;

ptr=ptr->next;

if(flag==0){

printf("login failed :(\n");

20
void signup(){

char name[30],mob[30];

struct node *nn,*ptr;

int flag=0;

printf("\nEnter Username : ");

scanf("%s",name);

printf("\nEnter Mobile Number : ");

scanf("%s",mob);

nn=(struct node *)malloc(sizeof(struct node));

strcpy(nn->name,name);

strcpy(nn->mob,mob);

strcpy(nn->status,"allocated");

ptr=start;

if(ptr==NULL){

start=nn;

nn->next=NULL;

nn->prev=NULL;

nn->f=NULL;nn->r=NULL;nn->top=NULL;

nn->codeid=1;

printf("\nSignup Succesfull :)\n");

21
}

else{

while(ptr!=NULL){

if(strcmp(ptr->status,"unallocated")==0){

flag=1;

strcpy(ptr->name,name);

strcpy(ptr->mob,mob);

strcpy(ptr->status,"allocated");

ptr->f=NULL;ptr->r=NULL;ptr->top=NULL;

break;

ptr=ptr->next;

if(flag==1){

printf("\nSignup Succesfull :)\n");

else{

ptr=start;

while(ptr->next!=NULL){

22
ptr=ptr->next;

nn->prev=ptr;

ptr->next=nn;

nn->next=NULL;

nn->codeid=nn->prev->codeid+1;

nn->f=NULL;nn->r=NULL;nn->top=NULL;

printf("\nSignup Succesfull :)\n");

void admin(){

int opt;

while(1){

printf("\nEnter Your Choice :\n");

printf("\n1.Search a Record\n2.View all Records\n3.logout\n\n");

scanf("%d",&opt);

switch(opt){

case 1:

searchRec();

23
break;

case 2:

viewAllRec();

break;

case 3:

startup();

break;

default:

printf("\nWrong Option Pressed :(\n");

void startup(){

int opt;

while(1){

printf("\nEnter Your Choice :\n");

printf("\n1.Admin Panel\n2.signup\n3.login\n4.leave\n5.Exit\n");

scanf("%d",&opt);

switch(opt){

24
case 1:

admin();

break;

case 2:

signup();

break;

case 3:

login();

break;

case 4:

leave();

break;

case 5:

printf("\nProgram Ended Successfully :) \n\n");

exit(0);

default:

printf("\nWrong Option Pressed :( \n");

25
}

int main(void){

startup();

return(0);

26
CHAPTER-4

4 RESULTS

Figure 4 Main page of application

27
Figure 5 User-1 Signup

28
Figure 6 User-2 Signup

29
Figure 7 User-1 Login

30
Figure 8 User-2 Login

31
Figure 9 Message sending by user-1

32
Figure 10 Message seen by user-2

33
Figure 11 Admin page

34
Figure 12 View all records by admin

35
CHAPTER-5

5 CONCLUSION

Real time chat is virtually any online communication that provides a real
time or live transmission of text messages from sender to receiver. It’s
lightweight to use the terminal for our chat, as there is no opening of the
browser, loading of JS libraries or any frontend code. Also, it allows us to
quickly test our ideas without worrying about what the user interface would
look like.

36
CHAPTER-6

6 BIBILOGRAPHY

[1] Monroe, Tony. "cowsay source code, CHANGELOG". Archived


from the original on 2012-02-13. Retrieved 2012-04-24.
[2] Orr, Mike (June 2001). "cowsay--ASCII Art for Your Screen". Linux
Gazette. Archived from the original on 2012-03-19. Retrieved 2012-04-
24.
[3] Newborough, Philip (2007-10-05). "A Virtual Richard Stallman for
Cowsay Hack". Archived from the original on 2011-07-25.
[4] Beshenov, Alexey (2007-10-28). "cowsay: a configurable talking and
thinking cow". Debian Package of the Day. Archived from the
original on 2007-10-30.
[5] Jump up to:a b Characters other than printable in C0 controls and basic
Latin (U+0021–U+007E) will not display properly as these parameters
accept only the first two bytes of input value. Using a pre-defined cow-
face will over-ride any value of -e and -T.
[6] March S., and Smith, S. (1995): Design and Natural Science Research
on
[7] Oates, B. (2006): Researching Information Systems and Computing.
London: Publications.
[8] Madden A .D., (2000): "A definition of information", Aslib
Proceedings, Vol. 52 Iss: 9, pp.343 – 349.

37
[9] Badre, A. (2002): Shaping Web Usability. Boston: Pearson Education,
Inc.
[10] Banfield, E. G. (1989): International Social Science. New York:
Vander

38

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy