SlideShare a Scribd company logo
1 of 5
Download to read offline
S O F T W A R E S E C T I O N
ELECTRONICS FOR YOU JUNE 2003
SOFT WARE SECTION
LOKESH KUMAR
PUZZLEGAME
H
ere’s a puzzle game implemented
through a program written in C
with graphics mode. The program,
when compiled and run, leads you to a
screen containing 16 small squares en-
closed in a square board. There are 15
numbers placed in 15 squares, the 16th
square being left blank. The numbers in
the squares are randomly arranged. The
players have to arrange the numbers in
ascending order in minimum number of
moves through navigation (arrow) keys.
This program is designed for two
game players. The first player attempts to
arrange the numbers in ascending
order in minimum number of moves to
finish the game. Every move is recorded
and shown in the scoreboard at the
upper right-hand corner of the screen.
When the player completes the puzzle, he
must note down the total number of moves
made by him from the scoreboard. Now
the second player attempts to arrange the
numbers in ascending order in minimum
number of moves and the number of
moves made by him are displayed on the
scoreboard. The player who completes
the puzzle with the least number of moves
is the winner.
To get started, double click on the file
puzzle.exe or, if you are using DOS
prompt, type ‘puzzle’ (or whatever name
you choose to save in your system). When
the first screen appears, press any key to
SANI THEO
continue. Now you get the final screen
containing 16 small squares in a square
board as shown in the screenshot. Use
navigation keys or up/down arrow keys
to move the desired number into blank
box, in order to arrange the numbers in
the ascending order. Press Esc key to quit
PUZZLE.C
//Program to play puzzle by Lokesh
Kumar(A.M.I.E.),DOEACC-'A' Level
//One can reach me at clokeshc@yahoo.com
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<string.h>
#include<stdlib.h>
//Function prototypes
void check(void);
void box();
void move(int k,int*);
int getkey();
int valid(int,int);
//Global variables
int game[16]={1,4,15,7,8,10,2,11,14,3,6,13,12,9,5,0};
int chance=0,p=15;
void main()
{
int gd=VGA,gm=VGAHI;
int k,i,j,s;
initgraph(&gd,&gm,"c:tcbgi");
cleardevice();
settextstyle(1,0,3);
setbkcolor(1);
setcolor(14);
settextstyle(3,0,3);
outtextxy(50,140,"Game created by Lokesh Kumar");
outtextxy(50,200,"A.M.I.E(Computer Engineer),Doeacc-
A Level");
outtextxy(50,260,"Exclusively for Electronics For You");
settextstyle(1,0,3);
setcolor(10);
outtextxy(90,400,"Press Any Key To Continue.....");
getch();
cleardevice();
setbkcolor(0);
while(1)
{
box();
k=getkey();
if(k==1)
{
cleardevice();
settextstyle(1,0,7);
setcolor(10);
setbkcolor(6);
outtextxy(30,100,"Hey you coward !");
settextstyle(1,0,5);
outtextxy(5,300," Never show your face again");
getch();
exit(1);
}//end if
if(!valid(p,k))
{
sound(2000); delay(1000); nosound();
continue;
the game. As you press Esc key, the
screen shows an unfriendly message. By
further pressing Esc key, you can exit the
program.
Note. The source code, executable file,
and other relevant files for this game will
be included in the next month’s EFY-CD.
Screenshot of puzzle game
S O F T W A R E S E C T I O N
ELECTRONICS FOR YOUJUNE 2003
}
chance++;
move(k,&p);
} //end while
} //end main
void box()
{
int f,r,c;
settextstyle(3,0,6);
setcolor(5);
outtextxy(200,25,"Puzzle X");
settextstyle(2,0,5);
setcolor(3);
outtextxy(480,200,"Use Arrow Keys");
outtextxy(480,220,"LEFT-RIGHT-UP-DOWN");
settextstyle(3,0,2);
setcolor(12);
outtextxy(200,430,"Press Esc to Exit");
setcolor(14);
rectangle(150,100,450,400);
line(225,100,225,400);
line(300,100,300,400);
line(375,100,375,400);
line(150,175,450,175);
line(150,250,450,250);
line(150,325,450,325);
gotoxy(24,9);
printf("%d ",game[0]);
gotoxy(34,9);
printf("%d ",game[1]);
gotoxy(44,9);
printf("%d ",game[2]);
gotoxy(52,9);
printf("%d ",game[3]);
gotoxy(24,14);
printf("%d ",game[4]);
gotoxy(34,14);
printf("%d ",game[5]);
gotoxy(44,14);
printf("%d ",game[6]);
gotoxy(52,14);
printf("%d ",game[7]);
gotoxy(24,19);
printf("%d ",game[8]);
gotoxy(34,19);
printf("%d ",game[9]);
gotoxy(44,19);
printf("%d ",game[10]);
gotoxy(52,19);
printf("%d ",game[11]);
gotoxy(24,23);
printf("%d ",game[12]);
gotoxy(34,23);
printf("%d ",game[13]);
gotoxy(44,23);
printf("%d ",game[14]);
gotoxy(52,23);
printf("%d ",game[15]);
for(f=0;f<=15;f++)
{
if(game[f]==0)
{
if(p<4)
r=9;
if(p>=4 && p<8)
r=14;
if(p>=8 && p<12)
r=19;
if(p>=12 && p<16)
r=23;
if(p==0 || p==4 || p==8 || p==12)
c=24;
if(p==1 || p==5 || p==9 || p==13)
c=34;
if(p==2 || p==6 || p==10 || p==14)
c=44;
if(p==3 || p==7 || p==11 || p==15)
c=52;
}
}
gotoxy(c,r);
printf(" ");
rectangle(425,20,630,60);
gotoxy(55,3);
printf("Your Total moves %d ",chance);
}
int getkey()
{
union REGS i,o;
while (!kbhit())
;
i.h.ah = 0;
int86 (22,&i,&o);
return (o.h.ah);
}
int valid(int b,int k)
{
if(b>=0 && b<=3 && k==80)
return 0;
if(b>=12 && b<=15 && k==72)
return 0;
if(b%4==0 && k==77)
return 0;
if((b==3||b==7||b==11||b==15) && k==75)
return 0;
return 1;
}
void move(int key,int *place)
{
if (key==80)
{
game[*place]=game[*place-4];
game[*place-4]=0;
*place=*place-4;
}
if (key==72)
{
game[*place]=game[*place+4];
game[*place+4]=0;
*place=*place+4;
}
if (key==77)
{
game[*place]=game[*place-1];
game[*place-1]=0;
*place=*place-1;
}
if (key==75)
{
game[*place]=game[*place+1];
game[*place+1]=0;
*place=*place+1;
}
check();
}
void check()
{
int a,i,j;
for(a=0;a<15;a++)
if (game[a]!=a+1)
return ;
box();
gotoxy(60,3);
printf("Your Total moves %d ",chance+1);
settextstyle(1,0,3);
for(a=0;a<=50;a++)
{
setcolor(a);
setbkcolor(a-31);
delay(0.5);
outtextxy(85,450,"Congratulations ! you made it");
for(i=0;i<1000;i++)
{
j=i>500?j-10*i:j+i*10;
sound(j/5);
delay(0.9);
}
delay(100);
}
nosound();
exit(1);
}//This is end of program at line number 220
❑
S O F T W A R E S E C T I O N
ELECTRONICS FOR YOUJULY 2003
SOFT WARE SECTION
LOKESH KUMAR
CUSTOMER INFORMATION SYSTEM
P
eople in organisations come across
many a person in their day-to-day
life. In order to have instant access
to any person, it is essential for the
organisations to maintain the contact ad-
dresses, telephone number, etc of impor-
tant persons in an organised manner. This
can be successfully achieved with a PC.
Here’s a program written in C++ that
makes this possible. Note that it is not a
graphics-based program.
After compilation when you run
the program, it prompts you to press any
key. On pressing any key from the
keyboard, the main menu appears
on the screen as shown in the screenshot.
The main menu has options like
Add Records, List Records, Modify
Records, Delete Records, Recall Records,
Pack Records, Search Records, and
Exit. The details of these options are as
follows:
1. Add Records: It allows you to add
new records.
2. List Records: It shows all the records
page by page.
3. Modify Records: To modify the con-
tents of the existing records.
SANI THEO
4. Delete Records: To delete any record.
5. Recall Records: To recover all the
deleted records.
6. Pack Records: This option com-
pletely removes all the deleted records.
Note that once this option has been se-
lected, the deleted files cannot be recov-
ered.
7. Search Records: To search a par-
ticular record from the existing records.
8. Exit: It allows you to quit from the
INFO.CPP
/*
Program Name : Customer Information System
Purpose: Keeps tracks of critical customer data
and generates reports like mailing list,
envelopes printing etc.
Created by : Lokesh Kumar(A.M.I.E),DOEACC-'A'
Level*/
#include <stdio.h>
#include <conio.h>
#include <fstream.h>
#include <string.h>
#include <stdlib.h>
#include <iomanip.h>
#include <process.h>
#define stopleft 218
#define stophori 196
#define stopright 191
#define sbottomleft 192
#define sbottomhori 196
#define sbottomright 217
#define sside 179
#define dtopleft 201
#define dtophori 205
#define dtopright 187
#define dbottomleft 200
#define dbottomhori 205
#define dbottomright 188
#define dside 186
#define no_of_menu_items 8
void DrawLine(int, int, int);
void DrawLine(int);
void DrawRect(int,int,int,int);
char *menu_items[] ={
"(1)Add records ",
"(2)List",
"(3)Modify",
"(4)Delete",
"(5)Recall",
"(6)Pack",
"(7)Search",
"(0)Exit"
};
void DrawRect(int x1, int y1, int x2, int y2)
{
int ox1 = x1, oy1 = y1, ox2 = x2, oy2 = y2;
gotoxy(x1++,y1); putchar(stopleft);
for(; x1 < x2; x1++)
{
gotoxy(x1,y1);
putchar(stophori);
}
gotoxy(x2,y1); putchar(stopright);
x1 = ox1, y1 = oy1, x2 = ox2, y2 = oy2;
gotoxy(x1++,y2); putchar(sbottomleft);
for(; x1 < x2; x1++)
{
gotoxy(x1,y2);
putchar(stophori);
}
gotoxy(x2,y2); putchar(sbottomright);
x1 = ox1, y1 = oy1 + 1, x2 = ox2, y2 = oy2;
for(; y1 < y2; y1++)
{
gotoxy(x1,y1);
putchar(sside);
}
x1 = ox1, y1 = ++oy1, x2 = ox2, y2 = oy2;
for(; y1 < y2; y1++)
{
gotoxy(x2,y1);
putchar(sside);
}
}
program.
The parameters or details which you
can enter in this application are identifica-
tion (ID), first name, last name, address 1,
address 2, city, phone number. All these
details are stored in a .dat file. The ‘temp’
is another .dat file which contains deleted
items.
Note. The source code and .exe
file will be included in the next month’s
EFY-CD.
Main menu of customer information system
S O F T W A R E S E C T I O N
ELECTRONICS FOR YOU JULY 2003
void DDrawRect(int x1, int y1, int x2, int y2)
{
int ox1 = x1, oy1 = y1, ox2 = x2, oy2 = y2;
gotoxy(x1++,y1); putchar(dtopleft);
for(; x1 < x2; x1++)
{
gotoxy(x1,y1);
putchar(dtophori);
}
gotoxy(x2,y1); putchar(dtopright);
x1 = ox1, y1 = oy1, x2 = ox2, y2 = oy2;
gotoxy(x1++,y2); putchar(dbottomleft);
for(; x1 < x2; x1++)
{
gotoxy(x1,y2);
putchar(dtophori);
}
gotoxy(x2,y2); putchar(dbottomright);
x1 = ox1, y1 = oy1 + 1, x2 = ox2, y2 = oy2;
for(; y1 < y2; y1++)
{
gotoxy(x1,y1);
putchar(dside);
}
x1 = ox1, y1 = ++oy1, x2 = ox2, y2 = oy2;
for(; y1 < y2; y1++)
{
gotoxy(x2,y1);
putchar(dside);
}
}
void DrawLine(int x1, int y1, int len)
{
for (; x1<len; x1++)
{
gotoxy(x1,y1); printf("-");
}
}
void DrawLine(int len)
{
for (int j = 0; j < len; j++)
printf("-");
}
class MailSystem
{
private:
struct address
{
char flag;
char id[5];
char fname[50];
char lname[50];
char add1[50];
char add2[50];
char city[50];
char phone[10];
}Mail;
fstream file;
public:
MailSystem();
void Add();
void List();
void Modify();
void Del();
void Recall();
void Pack();
void Exit();
void Splash();
int Search();
void Menu();
}m;
void MailSystem::Menu()
{
char choice;
do {
clrscr();
DDrawRect(15,4,60,20);
DrawRect(16,5,59,7);
gotoxy(24,6);
cout << "Customer Information System";
gotoxy(30,8);
cout << "1. Add records";
gotoxy(30,9);
cout << "2. List records";
gotoxy(30,10);
cout << "3. Modify records";
gotoxy(30,11);
cout << "4. Delete records";
gotoxy(30,12);
cout << "5. Recall records";
gotoxy(30,13);
cout << "6. Pack records";
gotoxy(30,14);
cout << "7. Search";
gotoxy(30,15);
cout << "0. Exit";
lblChoice:
gotoxy(30,16);
cout << "Your choice? ";
choice = getchar();
if (choice == 'n')
goto lblChoice;
clrscr();
switch(choice)
{
case '1':m.Add(); break;
case '2':m.List(); break;
case '3':m.Modify(); break;
case '4':m.Del(); break;
case '5':m.Recall(); break;
case '6':m.Pack(); break;
case '7':if (m.Search()) {
cout << endl << "Press any
key...";
}
else
{
cout << "Record not found
!!!";
}
getch(); break;
case '0':m.Exit(); break;
}
}while (choice != 0);
}
int MailSystem::Search()
{
char id[5];
cout << "Enter code :";
cin >> id;
file.clear();
file.seekg(0L,ios::beg);
while (file.read((char *)&Mail, sizeof(Mail)))
{
if (strcmp(Mail.id,id) == 0)
{
cout << Mail.fname << ",";
cout << Mail.lname << ",";
cout << Mail.add1<<",";
cout << Mail.add2 << ",";
cout << Mail.city << ",";
cout << Mail.phone;
return 1;
} // end if
} // end while
return 0;
}
void MailSystem::Splash()
{
clrscr();
gotoxy(28,5); printf("Customer Management System");
DrawLine(15,6,66);
gotoxy(15,7); printf("Purpose : Manages customer
contact information");
gotoxy(15,8); printf("Developed By : Lokesh Kumar
(Udaipur)");
DrawLine(15,9,66);
gotoxy(28,12); printf("Press any key to continue...");
getch();
}
void MailSystem::MailSystem()
{
file.open("mail.dat",ios::binary|ios::in|ios::out);
if (!file) {
cout << endl << "Unable to open file";
Exit();
}
}
void MailSystem::Add()
{
char ch;
file.seekp(0L,ios::end);
do {
fflush(stdin);
cout << endl << "Enter code : " << endl;
gets(Mail.id);
fflush(stdin);
cout << endl << "Enter first name : " << endl;
gets(Mail.fname);
fflush(stdin);
cout << endl << "Enter last name : " << endl;
gets(Mail.lname);
fflush(stdin);
cout << endl << "Address : " << endl;
gets(Mail.add1);
fflush(stdin);
cout << endl << "Street : " << endl;
gets(Mail.add2);
fflush(stdin);
cout << endl << "City : " << endl;
gets(Mail.city);
fflush(stdin);
cout << endl << "Phone : " << endl;
cin >> Mail.phone;
Mail.flag = ' ';
file.write((char *)&Mail,sizeof(Mail));
cout << "Add another record ?(Y/N) ";
cin >> ch;
fflush(stdin);
} while (ch == 'y' || ch == 'Y');
}
void MailSystem::List()
{
int a,line = 0;
file.seekg(0L,ios::beg);
//cout << endl << "Record# " ;
cout << "Listing of customers..."<<endl;
cout << "-----------------------"<<endl;
while (file.read((char *)&Mail, sizeof(Mail)))
{
if (Mail.flag != '*')
cout << "ID : " << Mail.id << endl;
cout << "Name : " << Mail.fname << " "<<
Mail.lname << endl;
cout << "Address : " << Mail.add1 << endl;
cout << " " << Mail.add2 << endl;
cout << "City : " << Mail.city << " Phone : "
<< Mail.phone << endl;
DrawLine(60);
line++;
if (line== 3) {
printf("npress any key to continue...");
getch();
line = 0;
}
S O F T W A R E S E C T I O N
ELECTRONICS FOR YOUJULY 2003
cout << endl;
}
file.clear();
cout << endl << "Press any key...";
getch();
}
void MailSystem::Modify()
{
char id[5];
int count = 0;
long int pos;
cout << "Enter code :";
cin >> id;
file.seekg(0L,ios::beg);
while (file.read((char *)&Mail, sizeof(Mail)))
{
if (strcmp(Mail.id,id) == 0)
{
cout << endl << "Enter first name : " << endl;
cin >> Mail.fname;
cout << endl << "Enter last name : " << endl;
cin >> Mail.lname;
cout << endl << "Address : " << endl;
cin >> Mail.add1;
cout << endl << "Street : " << endl;
cin >> Mail.add2;
cout << endl << "City : " << endl;
cin >> Mail.city;
cout << endl << "Phone : " << endl;
cin >> Mail.phone;
Mail.flag = ' ';
pos = count * sizeof(Mail);
file.seekp(pos,ios::beg);
file.write((char *)&Mail,sizeof(Mail));
return;
}// end if
count ++;
}// end while
cout << endl << "No employee in file with code =
" << id;
cout << endl << "Press any key...";
getch();
file.clear();
}
void MailSystem::Del()
{
char id[5];
long int pos;
int count = 0;
cout << "Enter code : ";
cin >> id;
file.seekg(0L,ios::beg);
while (file.read((char *)&Mail,sizeof(Mail)))
{
if (strcmp(Mail.id,id) == 0)
{
Mail.flag = '*';
pos = count * sizeof(Mail);
file.seekp(pos,ios::beg);
file.write((char *)&Mail,sizeof(Mail));
return;
}
count ++;
}
cout << endl << "No employee in file with code =
" << id;
cout << endl << "Press any key...";
getch();
file.clear();
}
void MailSystem::Recall()
{
char id[5];
long int pos;
int count = 0;
cout << "Enter code : ";
cin >> id;
file.seekg(0L,ios::beg);
while (file.read((char *)&Mail,sizeof(Mail)))
{
if (strcmp(Mail.id,id) == 0)
{
Mail.flag = ' ';
pos = count * sizeof(Mail);
file.seekp(pos,ios::beg);
file.write((char *)&Mail, sizeof(Mail));
return;
}
count ++;
}
cout << endl << "No employee in file with code =
" << id;
cout << endl << "Press any key...";
getch();
file.clear();
}
void MailSystem::Pack()
{
ofstream outfile;
outfile.open("temp",ios::out);
file.seekg(0L,ios::beg);
while (file.read((char *)&Mail,sizeof(Mail)))
{
if (Mail.flag != '*')
outfile.write((char *)&Mail,sizeof(Mail));
}
outfile.close();
file.close();
remove("mail.dat");
rename("temp","mail.dat");
file.open("mail.dat",ios::binary|ios::in|ios::out|ios::nocreate);
}
void MailSystem::Exit()
{
cout << "Releasing memory..." << endl;
cout << "Closing file..."<<endl;
cout << "Application closed.";
file.close();
exit(1);
}
void main()
{
MailSystem m;
_setcursortype(_NOCURSOR);
m.Splash();
_setcursortype(_NORMALCURSOR);
m.Menu();
}//This is end of program at line number 437
❑

More Related Content

What's hot

The Ring programming language version 1.2 book - Part 34 of 84
The Ring programming language version 1.2 book - Part 34 of 84The Ring programming language version 1.2 book - Part 34 of 84
The Ring programming language version 1.2 book - Part 34 of 84Mahmoud Samir Fayed
 
Artificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe gameArtificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe gamemanika kumari
 
Project 2
Project 2Project 2
Project 2umtkrc
 
Tic tac toe c++ programing
Tic tac toe c++ programingTic tac toe c++ programing
Tic tac toe c++ programingKrishna Agarwal
 
DiceSimulatorProgram
DiceSimulatorProgramDiceSimulatorProgram
DiceSimulatorProgramAmy Baxter
 
ejemplos gambas
ejemplos gambasejemplos gambas
ejemplos gambaseduann
 
Creating masterpieces with raphael
Creating masterpieces with raphaelCreating masterpieces with raphael
Creating masterpieces with raphaelPippi Labradoodle
 
Computer short cut key
Computer short cut keyComputer short cut key
Computer short cut keyJIN KHATRI
 
Bouncingballs sh
Bouncingballs shBouncingballs sh
Bouncingballs shBen Pope
 
Visual Basic
Visual BasicVisual Basic
Visual BasicVj NiroSh
 
AI based Tic Tac Toe game using Minimax Algorithm
AI based Tic Tac Toe game using Minimax AlgorithmAI based Tic Tac Toe game using Minimax Algorithm
AI based Tic Tac Toe game using Minimax AlgorithmKiran Shahi
 
Tic tac toe c++ project presentation
Tic tac toe c++ project presentationTic tac toe c++ project presentation
Tic tac toe c++ project presentationSaad Symbian
 
Paint program in c language
Paint program in c languagePaint program in c language
Paint program in c languagebit allahabad
 
Keyboard shortcuts
Keyboard shortcutsKeyboard shortcuts
Keyboard shortcutsAshish Yadav
 
Keyboard shortcuts
Keyboard shortcutsKeyboard shortcuts
Keyboard shortcutsaseener
 

What's hot (20)

The Ring programming language version 1.2 book - Part 34 of 84
The Ring programming language version 1.2 book - Part 34 of 84The Ring programming language version 1.2 book - Part 34 of 84
The Ring programming language version 1.2 book - Part 34 of 84
 
Artificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe gameArtificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe game
 
Project 2
Project 2Project 2
Project 2
 
Tic tac toe c++ programing
Tic tac toe c++ programingTic tac toe c++ programing
Tic tac toe c++ programing
 
DiceSimulatorProgram
DiceSimulatorProgramDiceSimulatorProgram
DiceSimulatorProgram
 
ejemplos gambas
ejemplos gambasejemplos gambas
ejemplos gambas
 
Creating masterpieces with raphael
Creating masterpieces with raphaelCreating masterpieces with raphael
Creating masterpieces with raphael
 
Computer short cut key
Computer short cut keyComputer short cut key
Computer short cut key
 
Bouncingballs sh
Bouncingballs shBouncingballs sh
Bouncingballs sh
 
Computer keyboard shortcuts
Computer keyboard shortcutsComputer keyboard shortcuts
Computer keyboard shortcuts
 
Visual Basic
Visual BasicVisual Basic
Visual Basic
 
AI based Tic Tac Toe game using Minimax Algorithm
AI based Tic Tac Toe game using Minimax AlgorithmAI based Tic Tac Toe game using Minimax Algorithm
AI based Tic Tac Toe game using Minimax Algorithm
 
Data Structure
Data StructureData Structure
Data Structure
 
Tic tac toe c++ project presentation
Tic tac toe c++ project presentationTic tac toe c++ project presentation
Tic tac toe c++ project presentation
 
Paint program in c language
Paint program in c languagePaint program in c language
Paint program in c language
 
Microsoft
MicrosoftMicrosoft
Microsoft
 
Keyboard shortcuts
Keyboard shortcutsKeyboard shortcuts
Keyboard shortcuts
 
Keyboard shortcuts
Keyboard shortcutsKeyboard shortcuts
Keyboard shortcuts
 
Windows Phone: From Idea to Published Game in 75 minutes
Windows Phone: From Idea to Published Game in 75 minutesWindows Phone: From Idea to Published Game in 75 minutes
Windows Phone: From Idea to Published Game in 75 minutes
 
MS office shortcuts
MS  office shortcutsMS  office shortcuts
MS office shortcuts
 

Viewers also liked

SBP_Presentation_091203_JV
SBP_Presentation_091203_JVSBP_Presentation_091203_JV
SBP_Presentation_091203_JVDrew Loften
 
Techno wise
Techno wiseTechno wise
Techno wiseMayank K
 
Découvrez tous les avantages de la plateforme Bing Ads
Découvrez tous les avantages de la plateforme Bing AdsDécouvrez tous les avantages de la plateforme Bing Ads
Découvrez tous les avantages de la plateforme Bing Adssemrush_webinars
 
Молдове
Молдове Молдове
Молдове Nick535
 
The first to use geometry module 2
The first to use geometry module 2The first to use geometry module 2
The first to use geometry module 2kcloer
 

Viewers also liked (8)

SBP_Presentation_091203_JV
SBP_Presentation_091203_JVSBP_Presentation_091203_JV
SBP_Presentation_091203_JV
 
Techno wise
Techno wiseTechno wise
Techno wise
 
Découvrez tous les avantages de la plateforme Bing Ads
Découvrez tous les avantages de la plateforme Bing AdsDécouvrez tous les avantages de la plateforme Bing Ads
Découvrez tous les avantages de la plateforme Bing Ads
 
FPP Machado David
FPP Machado DavidFPP Machado David
FPP Machado David
 
Question 3 - evaluation
Question 3 - evaluationQuestion 3 - evaluation
Question 3 - evaluation
 
Молдове
Молдове Молдове
Молдове
 
The first to use geometry module 2
The first to use geometry module 2The first to use geometry module 2
The first to use geometry module 2
 
INDUSTRIA DE LA CERVEZA
INDUSTRIA DE LA CERVEZAINDUSTRIA DE LA CERVEZA
INDUSTRIA DE LA CERVEZA
 

Similar to efy-articles

ma project
ma projectma project
ma projectAisu
 
Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)Jaydip JK
 
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートIIopenFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートIIAtsushi Tadokoro
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in cgkgaur1987
 
The Ring programming language version 1.8 book - Part 66 of 202
The Ring programming language version 1.8 book - Part 66 of 202The Ring programming language version 1.8 book - Part 66 of 202
The Ring programming language version 1.8 book - Part 66 of 202Mahmoud Samir Fayed
 
Scientific calculator in c
Scientific calculator in cScientific calculator in c
Scientific calculator in cUpendra Sengar
 
Need to make a ReversiOthello Board game in JAVAThe board size ca.pdf
Need to make a ReversiOthello Board game in JAVAThe board size ca.pdfNeed to make a ReversiOthello Board game in JAVAThe board size ca.pdf
Need to make a ReversiOthello Board game in JAVAThe board size ca.pdfflashfashioncasualwe
 
Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming
Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming
Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming Badhon Biswas
 
Artificial intelligence - python
Artificial intelligence - pythonArtificial intelligence - python
Artificial intelligence - pythonSunjid Hasan
 
The Ring programming language version 1.10 book - Part 71 of 212
The Ring programming language version 1.10 book - Part 71 of 212The Ring programming language version 1.10 book - Part 71 of 212
The Ring programming language version 1.10 book - Part 71 of 212Mahmoud Samir Fayed
 
1 ECE 175 Computer Programming for Engineering Applica.docx
1  ECE 175 Computer Programming for Engineering Applica.docx1  ECE 175 Computer Programming for Engineering Applica.docx
1 ECE 175 Computer Programming for Engineering Applica.docxoswald1horne84988
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101premrings
 
Computer graphics
Computer graphicsComputer graphics
Computer graphicssnelkoli
 

Similar to efy-articles (20)

ma project
ma projectma project
ma project
 
135
135135
135
 
C questions
C questionsC questions
C questions
 
Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)
 
pattern-printing-in-c.pdf
pattern-printing-in-c.pdfpattern-printing-in-c.pdf
pattern-printing-in-c.pdf
 
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートIIopenFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII
openFrameworks – 関数・クラス、オブジェクト指向プログラミング導入 - 多摩美メディアアートII
 
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
 
The Ring programming language version 1.8 book - Part 66 of 202
The Ring programming language version 1.8 book - Part 66 of 202The Ring programming language version 1.8 book - Part 66 of 202
The Ring programming language version 1.8 book - Part 66 of 202
 
Basic standard calculator
Basic standard calculatorBasic standard calculator
Basic standard calculator
 
Scientific calculator in c
Scientific calculator in cScientific calculator in c
Scientific calculator in c
 
Need to make a ReversiOthello Board game in JAVAThe board size ca.pdf
Need to make a ReversiOthello Board game in JAVAThe board size ca.pdfNeed to make a ReversiOthello Board game in JAVAThe board size ca.pdf
Need to make a ReversiOthello Board game in JAVAThe board size ca.pdf
 
Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming
Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming
Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming
 
Artificial intelligence - python
Artificial intelligence - pythonArtificial intelligence - python
Artificial intelligence - python
 
The Ring programming language version 1.10 book - Part 71 of 212
The Ring programming language version 1.10 book - Part 71 of 212The Ring programming language version 1.10 book - Part 71 of 212
The Ring programming language version 1.10 book - Part 71 of 212
 
Qno 1 (d)
Qno 1 (d)Qno 1 (d)
Qno 1 (d)
 
1 ECE 175 Computer Programming for Engineering Applica.docx
1  ECE 175 Computer Programming for Engineering Applica.docx1  ECE 175 Computer Programming for Engineering Applica.docx
1 ECE 175 Computer Programming for Engineering Applica.docx
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
Design problem
Design problemDesign problem
Design problem
 
Qno 1 (e)
Qno 1 (e)Qno 1 (e)
Qno 1 (e)
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 

efy-articles

  • 1. S O F T W A R E S E C T I O N ELECTRONICS FOR YOU JUNE 2003 SOFT WARE SECTION LOKESH KUMAR PUZZLEGAME H ere’s a puzzle game implemented through a program written in C with graphics mode. The program, when compiled and run, leads you to a screen containing 16 small squares en- closed in a square board. There are 15 numbers placed in 15 squares, the 16th square being left blank. The numbers in the squares are randomly arranged. The players have to arrange the numbers in ascending order in minimum number of moves through navigation (arrow) keys. This program is designed for two game players. The first player attempts to arrange the numbers in ascending order in minimum number of moves to finish the game. Every move is recorded and shown in the scoreboard at the upper right-hand corner of the screen. When the player completes the puzzle, he must note down the total number of moves made by him from the scoreboard. Now the second player attempts to arrange the numbers in ascending order in minimum number of moves and the number of moves made by him are displayed on the scoreboard. The player who completes the puzzle with the least number of moves is the winner. To get started, double click on the file puzzle.exe or, if you are using DOS prompt, type ‘puzzle’ (or whatever name you choose to save in your system). When the first screen appears, press any key to SANI THEO continue. Now you get the final screen containing 16 small squares in a square board as shown in the screenshot. Use navigation keys or up/down arrow keys to move the desired number into blank box, in order to arrange the numbers in the ascending order. Press Esc key to quit PUZZLE.C //Program to play puzzle by Lokesh Kumar(A.M.I.E.),DOEACC-'A' Level //One can reach me at clokeshc@yahoo.com #include<stdio.h> #include<conio.h> #include<graphics.h> #include<dos.h> #include<string.h> #include<stdlib.h> //Function prototypes void check(void); void box(); void move(int k,int*); int getkey(); int valid(int,int); //Global variables int game[16]={1,4,15,7,8,10,2,11,14,3,6,13,12,9,5,0}; int chance=0,p=15; void main() { int gd=VGA,gm=VGAHI; int k,i,j,s; initgraph(&gd,&gm,"c:tcbgi"); cleardevice(); settextstyle(1,0,3); setbkcolor(1); setcolor(14); settextstyle(3,0,3); outtextxy(50,140,"Game created by Lokesh Kumar"); outtextxy(50,200,"A.M.I.E(Computer Engineer),Doeacc- A Level"); outtextxy(50,260,"Exclusively for Electronics For You"); settextstyle(1,0,3); setcolor(10); outtextxy(90,400,"Press Any Key To Continue....."); getch(); cleardevice(); setbkcolor(0); while(1) { box(); k=getkey(); if(k==1) { cleardevice(); settextstyle(1,0,7); setcolor(10); setbkcolor(6); outtextxy(30,100,"Hey you coward !"); settextstyle(1,0,5); outtextxy(5,300," Never show your face again"); getch(); exit(1); }//end if if(!valid(p,k)) { sound(2000); delay(1000); nosound(); continue; the game. As you press Esc key, the screen shows an unfriendly message. By further pressing Esc key, you can exit the program. Note. The source code, executable file, and other relevant files for this game will be included in the next month’s EFY-CD. Screenshot of puzzle game
  • 2. S O F T W A R E S E C T I O N ELECTRONICS FOR YOUJUNE 2003 } chance++; move(k,&p); } //end while } //end main void box() { int f,r,c; settextstyle(3,0,6); setcolor(5); outtextxy(200,25,"Puzzle X"); settextstyle(2,0,5); setcolor(3); outtextxy(480,200,"Use Arrow Keys"); outtextxy(480,220,"LEFT-RIGHT-UP-DOWN"); settextstyle(3,0,2); setcolor(12); outtextxy(200,430,"Press Esc to Exit"); setcolor(14); rectangle(150,100,450,400); line(225,100,225,400); line(300,100,300,400); line(375,100,375,400); line(150,175,450,175); line(150,250,450,250); line(150,325,450,325); gotoxy(24,9); printf("%d ",game[0]); gotoxy(34,9); printf("%d ",game[1]); gotoxy(44,9); printf("%d ",game[2]); gotoxy(52,9); printf("%d ",game[3]); gotoxy(24,14); printf("%d ",game[4]); gotoxy(34,14); printf("%d ",game[5]); gotoxy(44,14); printf("%d ",game[6]); gotoxy(52,14); printf("%d ",game[7]); gotoxy(24,19); printf("%d ",game[8]); gotoxy(34,19); printf("%d ",game[9]); gotoxy(44,19); printf("%d ",game[10]); gotoxy(52,19); printf("%d ",game[11]); gotoxy(24,23); printf("%d ",game[12]); gotoxy(34,23); printf("%d ",game[13]); gotoxy(44,23); printf("%d ",game[14]); gotoxy(52,23); printf("%d ",game[15]); for(f=0;f<=15;f++) { if(game[f]==0) { if(p<4) r=9; if(p>=4 && p<8) r=14; if(p>=8 && p<12) r=19; if(p>=12 && p<16) r=23; if(p==0 || p==4 || p==8 || p==12) c=24; if(p==1 || p==5 || p==9 || p==13) c=34; if(p==2 || p==6 || p==10 || p==14) c=44; if(p==3 || p==7 || p==11 || p==15) c=52; } } gotoxy(c,r); printf(" "); rectangle(425,20,630,60); gotoxy(55,3); printf("Your Total moves %d ",chance); } int getkey() { union REGS i,o; while (!kbhit()) ; i.h.ah = 0; int86 (22,&i,&o); return (o.h.ah); } int valid(int b,int k) { if(b>=0 && b<=3 && k==80) return 0; if(b>=12 && b<=15 && k==72) return 0; if(b%4==0 && k==77) return 0; if((b==3||b==7||b==11||b==15) && k==75) return 0; return 1; } void move(int key,int *place) { if (key==80) { game[*place]=game[*place-4]; game[*place-4]=0; *place=*place-4; } if (key==72) { game[*place]=game[*place+4]; game[*place+4]=0; *place=*place+4; } if (key==77) { game[*place]=game[*place-1]; game[*place-1]=0; *place=*place-1; } if (key==75) { game[*place]=game[*place+1]; game[*place+1]=0; *place=*place+1; } check(); } void check() { int a,i,j; for(a=0;a<15;a++) if (game[a]!=a+1) return ; box(); gotoxy(60,3); printf("Your Total moves %d ",chance+1); settextstyle(1,0,3); for(a=0;a<=50;a++) { setcolor(a); setbkcolor(a-31); delay(0.5); outtextxy(85,450,"Congratulations ! you made it"); for(i=0;i<1000;i++) { j=i>500?j-10*i:j+i*10; sound(j/5); delay(0.9); } delay(100); } nosound(); exit(1); }//This is end of program at line number 220 ❑
  • 3. S O F T W A R E S E C T I O N ELECTRONICS FOR YOUJULY 2003 SOFT WARE SECTION LOKESH KUMAR CUSTOMER INFORMATION SYSTEM P eople in organisations come across many a person in their day-to-day life. In order to have instant access to any person, it is essential for the organisations to maintain the contact ad- dresses, telephone number, etc of impor- tant persons in an organised manner. This can be successfully achieved with a PC. Here’s a program written in C++ that makes this possible. Note that it is not a graphics-based program. After compilation when you run the program, it prompts you to press any key. On pressing any key from the keyboard, the main menu appears on the screen as shown in the screenshot. The main menu has options like Add Records, List Records, Modify Records, Delete Records, Recall Records, Pack Records, Search Records, and Exit. The details of these options are as follows: 1. Add Records: It allows you to add new records. 2. List Records: It shows all the records page by page. 3. Modify Records: To modify the con- tents of the existing records. SANI THEO 4. Delete Records: To delete any record. 5. Recall Records: To recover all the deleted records. 6. Pack Records: This option com- pletely removes all the deleted records. Note that once this option has been se- lected, the deleted files cannot be recov- ered. 7. Search Records: To search a par- ticular record from the existing records. 8. Exit: It allows you to quit from the INFO.CPP /* Program Name : Customer Information System Purpose: Keeps tracks of critical customer data and generates reports like mailing list, envelopes printing etc. Created by : Lokesh Kumar(A.M.I.E),DOEACC-'A' Level*/ #include <stdio.h> #include <conio.h> #include <fstream.h> #include <string.h> #include <stdlib.h> #include <iomanip.h> #include <process.h> #define stopleft 218 #define stophori 196 #define stopright 191 #define sbottomleft 192 #define sbottomhori 196 #define sbottomright 217 #define sside 179 #define dtopleft 201 #define dtophori 205 #define dtopright 187 #define dbottomleft 200 #define dbottomhori 205 #define dbottomright 188 #define dside 186 #define no_of_menu_items 8 void DrawLine(int, int, int); void DrawLine(int); void DrawRect(int,int,int,int); char *menu_items[] ={ "(1)Add records ", "(2)List", "(3)Modify", "(4)Delete", "(5)Recall", "(6)Pack", "(7)Search", "(0)Exit" }; void DrawRect(int x1, int y1, int x2, int y2) { int ox1 = x1, oy1 = y1, ox2 = x2, oy2 = y2; gotoxy(x1++,y1); putchar(stopleft); for(; x1 < x2; x1++) { gotoxy(x1,y1); putchar(stophori); } gotoxy(x2,y1); putchar(stopright); x1 = ox1, y1 = oy1, x2 = ox2, y2 = oy2; gotoxy(x1++,y2); putchar(sbottomleft); for(; x1 < x2; x1++) { gotoxy(x1,y2); putchar(stophori); } gotoxy(x2,y2); putchar(sbottomright); x1 = ox1, y1 = oy1 + 1, x2 = ox2, y2 = oy2; for(; y1 < y2; y1++) { gotoxy(x1,y1); putchar(sside); } x1 = ox1, y1 = ++oy1, x2 = ox2, y2 = oy2; for(; y1 < y2; y1++) { gotoxy(x2,y1); putchar(sside); } } program. The parameters or details which you can enter in this application are identifica- tion (ID), first name, last name, address 1, address 2, city, phone number. All these details are stored in a .dat file. The ‘temp’ is another .dat file which contains deleted items. Note. The source code and .exe file will be included in the next month’s EFY-CD. Main menu of customer information system
  • 4. S O F T W A R E S E C T I O N ELECTRONICS FOR YOU JULY 2003 void DDrawRect(int x1, int y1, int x2, int y2) { int ox1 = x1, oy1 = y1, ox2 = x2, oy2 = y2; gotoxy(x1++,y1); putchar(dtopleft); for(; x1 < x2; x1++) { gotoxy(x1,y1); putchar(dtophori); } gotoxy(x2,y1); putchar(dtopright); x1 = ox1, y1 = oy1, x2 = ox2, y2 = oy2; gotoxy(x1++,y2); putchar(dbottomleft); for(; x1 < x2; x1++) { gotoxy(x1,y2); putchar(dtophori); } gotoxy(x2,y2); putchar(dbottomright); x1 = ox1, y1 = oy1 + 1, x2 = ox2, y2 = oy2; for(; y1 < y2; y1++) { gotoxy(x1,y1); putchar(dside); } x1 = ox1, y1 = ++oy1, x2 = ox2, y2 = oy2; for(; y1 < y2; y1++) { gotoxy(x2,y1); putchar(dside); } } void DrawLine(int x1, int y1, int len) { for (; x1<len; x1++) { gotoxy(x1,y1); printf("-"); } } void DrawLine(int len) { for (int j = 0; j < len; j++) printf("-"); } class MailSystem { private: struct address { char flag; char id[5]; char fname[50]; char lname[50]; char add1[50]; char add2[50]; char city[50]; char phone[10]; }Mail; fstream file; public: MailSystem(); void Add(); void List(); void Modify(); void Del(); void Recall(); void Pack(); void Exit(); void Splash(); int Search(); void Menu(); }m; void MailSystem::Menu() { char choice; do { clrscr(); DDrawRect(15,4,60,20); DrawRect(16,5,59,7); gotoxy(24,6); cout << "Customer Information System"; gotoxy(30,8); cout << "1. Add records"; gotoxy(30,9); cout << "2. List records"; gotoxy(30,10); cout << "3. Modify records"; gotoxy(30,11); cout << "4. Delete records"; gotoxy(30,12); cout << "5. Recall records"; gotoxy(30,13); cout << "6. Pack records"; gotoxy(30,14); cout << "7. Search"; gotoxy(30,15); cout << "0. Exit"; lblChoice: gotoxy(30,16); cout << "Your choice? "; choice = getchar(); if (choice == 'n') goto lblChoice; clrscr(); switch(choice) { case '1':m.Add(); break; case '2':m.List(); break; case '3':m.Modify(); break; case '4':m.Del(); break; case '5':m.Recall(); break; case '6':m.Pack(); break; case '7':if (m.Search()) { cout << endl << "Press any key..."; } else { cout << "Record not found !!!"; } getch(); break; case '0':m.Exit(); break; } }while (choice != 0); } int MailSystem::Search() { char id[5]; cout << "Enter code :"; cin >> id; file.clear(); file.seekg(0L,ios::beg); while (file.read((char *)&Mail, sizeof(Mail))) { if (strcmp(Mail.id,id) == 0) { cout << Mail.fname << ","; cout << Mail.lname << ","; cout << Mail.add1<<","; cout << Mail.add2 << ","; cout << Mail.city << ","; cout << Mail.phone; return 1; } // end if } // end while return 0; } void MailSystem::Splash() { clrscr(); gotoxy(28,5); printf("Customer Management System"); DrawLine(15,6,66); gotoxy(15,7); printf("Purpose : Manages customer contact information"); gotoxy(15,8); printf("Developed By : Lokesh Kumar (Udaipur)"); DrawLine(15,9,66); gotoxy(28,12); printf("Press any key to continue..."); getch(); } void MailSystem::MailSystem() { file.open("mail.dat",ios::binary|ios::in|ios::out); if (!file) { cout << endl << "Unable to open file"; Exit(); } } void MailSystem::Add() { char ch; file.seekp(0L,ios::end); do { fflush(stdin); cout << endl << "Enter code : " << endl; gets(Mail.id); fflush(stdin); cout << endl << "Enter first name : " << endl; gets(Mail.fname); fflush(stdin); cout << endl << "Enter last name : " << endl; gets(Mail.lname); fflush(stdin); cout << endl << "Address : " << endl; gets(Mail.add1); fflush(stdin); cout << endl << "Street : " << endl; gets(Mail.add2); fflush(stdin); cout << endl << "City : " << endl; gets(Mail.city); fflush(stdin); cout << endl << "Phone : " << endl; cin >> Mail.phone; Mail.flag = ' '; file.write((char *)&Mail,sizeof(Mail)); cout << "Add another record ?(Y/N) "; cin >> ch; fflush(stdin); } while (ch == 'y' || ch == 'Y'); } void MailSystem::List() { int a,line = 0; file.seekg(0L,ios::beg); //cout << endl << "Record# " ; cout << "Listing of customers..."<<endl; cout << "-----------------------"<<endl; while (file.read((char *)&Mail, sizeof(Mail))) { if (Mail.flag != '*') cout << "ID : " << Mail.id << endl; cout << "Name : " << Mail.fname << " "<< Mail.lname << endl; cout << "Address : " << Mail.add1 << endl; cout << " " << Mail.add2 << endl; cout << "City : " << Mail.city << " Phone : " << Mail.phone << endl; DrawLine(60); line++; if (line== 3) { printf("npress any key to continue..."); getch(); line = 0; }
  • 5. S O F T W A R E S E C T I O N ELECTRONICS FOR YOUJULY 2003 cout << endl; } file.clear(); cout << endl << "Press any key..."; getch(); } void MailSystem::Modify() { char id[5]; int count = 0; long int pos; cout << "Enter code :"; cin >> id; file.seekg(0L,ios::beg); while (file.read((char *)&Mail, sizeof(Mail))) { if (strcmp(Mail.id,id) == 0) { cout << endl << "Enter first name : " << endl; cin >> Mail.fname; cout << endl << "Enter last name : " << endl; cin >> Mail.lname; cout << endl << "Address : " << endl; cin >> Mail.add1; cout << endl << "Street : " << endl; cin >> Mail.add2; cout << endl << "City : " << endl; cin >> Mail.city; cout << endl << "Phone : " << endl; cin >> Mail.phone; Mail.flag = ' '; pos = count * sizeof(Mail); file.seekp(pos,ios::beg); file.write((char *)&Mail,sizeof(Mail)); return; }// end if count ++; }// end while cout << endl << "No employee in file with code = " << id; cout << endl << "Press any key..."; getch(); file.clear(); } void MailSystem::Del() { char id[5]; long int pos; int count = 0; cout << "Enter code : "; cin >> id; file.seekg(0L,ios::beg); while (file.read((char *)&Mail,sizeof(Mail))) { if (strcmp(Mail.id,id) == 0) { Mail.flag = '*'; pos = count * sizeof(Mail); file.seekp(pos,ios::beg); file.write((char *)&Mail,sizeof(Mail)); return; } count ++; } cout << endl << "No employee in file with code = " << id; cout << endl << "Press any key..."; getch(); file.clear(); } void MailSystem::Recall() { char id[5]; long int pos; int count = 0; cout << "Enter code : "; cin >> id; file.seekg(0L,ios::beg); while (file.read((char *)&Mail,sizeof(Mail))) { if (strcmp(Mail.id,id) == 0) { Mail.flag = ' '; pos = count * sizeof(Mail); file.seekp(pos,ios::beg); file.write((char *)&Mail, sizeof(Mail)); return; } count ++; } cout << endl << "No employee in file with code = " << id; cout << endl << "Press any key..."; getch(); file.clear(); } void MailSystem::Pack() { ofstream outfile; outfile.open("temp",ios::out); file.seekg(0L,ios::beg); while (file.read((char *)&Mail,sizeof(Mail))) { if (Mail.flag != '*') outfile.write((char *)&Mail,sizeof(Mail)); } outfile.close(); file.close(); remove("mail.dat"); rename("temp","mail.dat"); file.open("mail.dat",ios::binary|ios::in|ios::out|ios::nocreate); } void MailSystem::Exit() { cout << "Releasing memory..." << endl; cout << "Closing file..."<<endl; cout << "Application closed."; file.close(); exit(1); } void main() { MailSystem m; _setcursortype(_NOCURSOR); m.Splash(); _setcursortype(_NORMALCURSOR); m.Menu(); }//This is end of program at line number 437 ❑