#include "mathalizer.h"
int multiply(int x, int y)
{
return x*y;
}
int add(int x, int y)
{
return x+y;
}
int ** create_table(int size, int (* oper) (int,int))
{
int x;
int y;
int **array;
if(size<1) return NULL;
array = (int **)malloc(size*sizeof(int*));
if(array==NULL) return 1;
for(x=0;x{
array[x]=(int*)malloc(size*sizeof(int));
}
for(x=0;x{
for(y=0;y{
array[x][y]=(* oper)(x,y);
}
}
return array;
}
int save_table(FILE * fp, int ** array, int size)
{
int x;
for(x=0;x{
fwrite(array[x],sizeof(int),size,fp);
}
fclose (fp);
return 1;
}
int ** load_table(FILE * file, int size)
{
int x;
int fread_return_code_2;
int **array2;
array2 = (int **)malloc(size*sizeof(int*));
if(array2==NULL) return 1;
for(x=0;x{
array2[x]=(int*)malloc(size*sizeof(int));
}
for(x=0;x{
fread_return_code_2=fread(array2[x],sizeof(int),size,file);
}
if(fread_return_code_2!=size) return 1;
fclose(file);
return array2;
}
memory corruption
ENCRYPTION DECRYPTION In C
void main()
{
FILE *fp,*fp1;
int choi;
char name[20],temp[20]={"Temp.txt"},c;
clrscr();
printf("
Press 1 to Encrypt:
Press 2 to Decrypt");
printf("
Enter your Choice:");
scanf("%d",&choi);
switch(choi)
{
case 1:
printf("Enter the filename to Encrypt:");
scanf("%s",name);
fp=fopen(name,"r+");
if(fp==NULL)
{
printf("The file %s can't be open",name);
getch();
exit();
}
fp1=fopen(temp,"w+");
if(fp1==NULL)
{
printf("The file Temp can't be open");
getch();
exit();
}
c=fgetc(fp);
while(c!=EOF)
{
fputc((c+name[0]),fp1);printf("%c",c+name[0]);getch();
c=fgetc(fp);
}
fclose(fp);
fclose(fp1);
remove(name);
rename(temp,name);
printf("The file is Encrypted:");
getch();
break;
case 2:
printf("
Enter the Filename to Decrypt:");
scanf("%s",name);
fp=fopen(name,"r+");
fp1=fopen(temp,"w+");
c=fgetc(fp);
while(c!=EOF)
{
fputc(c-name[0],fp1);
c=fgetc(fp);
}
fclose(fp);
fclose(fp1);
remove(name);
rename(temp,name);
printf("The file is decrypted:");
getch();
}
}
Related Links :
File Encryption Program in C.
#define ENCRYPTION_FORMULA (int) Byte + 25
#define DECRYPTION_FORMULA (int) Byte - 25
int Encrypt(char * FILENAME, char * NEW_FILENAME)
{
//printf("Loaded Encrypt");
FILE *inFile; //Declare inFile
FILE *outFile; //Declare outFile
char Byte;
char newByte;
int n;
printf("1");
int i=0;
inFile = fopen(FILENAME,"rb");
outFile = fopen(NEW_FILENAME, "w");
if(inFile==NULL)
printf("Error: Can't Open inFile");
if(outFile==NULL)
{
printf("Error: Can't open outFile.");
return 1;
}
else
{
printf("File Opened, Encrypting");
while(1)
{
printf(".");
if(Byte!=EOF)
{
Byte=fgetc(inFile);
// printf("%d",Byte);
newByte=Byte+25;
fputc(newByte,outFile);
}
else
{
printf("End of File");
break;
}
}
fclose(inFile);
fclose(outFile);
}
}
int Decrypt (char *FILENAME, char *NEW_FILENAME)
{
//printf("Loaded Decrypt");
FILE *inFile; //Declare inFile
FILE *outFile; //Declare outFile
char Byte;
char newByte;
printf("2");
int i=0;
inFile = fopen(FILENAME,"rb");
outFile = fopen(NEW_FILENAME, "w");
if(inFile==NULL)
printf("Error: Can't Open inFile");
if(outFile==NULL)
{
printf("Error: Can't open outFile.");
return 1;
}
else
{
printf("File Opened, Decrypting");
while(1)
{
printf(".");
if(Byte!=EOF)
{
Byte=fgetc(inFile);
// printf("%d",Byte);
newByte=Byte-25;
fputc(newByte,outFile);
}
else
{
printf("End of File");
break;
}
}
fclose(inFile);
fclose(outFile);
}
}
int main()
{
char encFile[200];
char newencFile[200];
char decFile[200];
char newdecFile[200];
int choice;
printf("NOTE: you must Decrypt the file with the same file
extension!!!");
printf("Enter 1 to Encrypt / 2 to Decrypt");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("Enter the Source Filename: ");
scanf("%s",&encFile);
printf("Enter the Destination Filename: ");
scanf("%s",&newencFile);
Encrypt(encFile, newencFile);
break;
case 2:
printf("Enter the Source Filename: ");
scanf("%s",&decFile);
printf("Enter the Destination Filename: ");
scanf("%s",&newdecFile);
Decrypt(decFile, newdecFile);
break;
}
return 0;
}
Related Links :
Mines Sweeper Game In C
// preprocessing
#include <stdio.h>
#define TRUE 1
#define FALSE 0
#define N 9
// for uncoverMine() return value
#define EMPTY 1
#define MINE 0
// for printType parameter in printBoard()
#define MENU_PRINT 0 // main menu board print
#define GAME_PRINT 1 // print board after square is checked
#define WON_PRINT 2 // print board after win
#define LOST_PRINT 3 // print board after mine hit - like MENU_PRINT?
// global Var decl
//! not alowed !//
// global function decl
int mainPlayGame(char board[N][N]);
void mainProgram(char board[N][N]);
void printBoard(char board[N][N],int size, int printType);
void mainMenu();
int insertMine(char board[N][N],char mines[],int size);
int removeMine(char board[N][N],int size,int x,int y);
int unCover(char board[N][N],int size,int x,int y);
int checkEndOfGame(char board[N][N],int size);
int playGame(char board[N][N],int size) ;
int main()
{
char board[N][N];
mainProgram (board);
printf("press ENTER to EXIT\n");
getchar();
return 0;
}
void mainProgram(char board[N][N])
{
//char* test_char_gil;
int size_defined = FALSE;
int size, i, row, col, menu_choice, x, y, lost;
int lost_times = 0;
int won_times = 0;
char menu_choice_buf[346], mines[40];
char coordinates[346];
char nothing[346];
//
while (TRUE)
{
mainMenu();
gets(menu_choice_buf);
// test input is ok
if (menu_choice_buf[0] < '0' || '5' < menu_choice_buf[0])
continue;
if (menu_choice_buf[1] != '\0')
continue;
// convert char to ints
menu_choice = menu_choice_buf[0] - 48;
// exit
if (menu_choice == 0)
{
if (won_times+lost_times == 0)
printf("you didn't play\n");
else
{
printf("you played %d game(s):\n", won_times+lost_times);
printf("you won %d\n", won_times);
printf("you lost %d\n", lost_times);
}
printf("bye!\n");
// print num of games
return;
}
// choose board size
if (menu_choice == 1)
{
size_defined = FALSE;
printf("enter board size [1..9] (no input control is needed):\n");
scanf ("%d", &size);
gets(nothing); // consuming the rest of the stdin buffer
if (0 < size && size < 10)
{
// initializing board
for (row = 0; row < size; row++)
for (col = 0; col < size; col++)
board[row][col] = ' ';
size_defined = TRUE;
}
continue;
}
// place mines
if (menu_choice == 2)
{
if (size_defined == FALSE)
{
printf("you must choose board size first!\n");
continue;
}
printf ("enter x,y of the new mines (x1,y1)(x2,y2)...(xn,yn):\n");
// initialize mins[]
for (i=0; i<40; i++)
mines[i]=' ';
// user inputs mine/s coordinates
gets(mines);
// testing user input and applying it to the board array
if (insertMine (board, mines, size) == FALSE)
printf("wrong input\n");
continue;
}
// remove mines
if (menu_choice == 3)
{
if (size_defined == FALSE)
{
printf("you must choose board size first!\n");
continue;
}
printf("enter x,y of the mine to remove (no input control is needed):\n");
// get coordinates and test input
gets(coordinates);
if ((coordinates[0] < '0') || ('9' < coordinates[2]))
continue;
if (coordinates[1] != ',')
continue;
if ((coordinates[2] < '0') || ('9' < coordinates[2]))
continue;
x = coordinates[0]-48;
y = coordinates[2]-48;
// remove if possible
if(removeMine(board, size, x, y) == FALSE)
printf("wrong input or no mine\n");
else
printf("mine removed\n");
// if not, print err msg
continue;
}
// show mines
if (menu_choice == 4)
{
if (size_defined == FALSE)
{
printf("you must choose board size first!\n");
continue;
}
printBoard(board, size, MENU_PRINT);
continue;
}
// start the game
if (menu_choice == 5)
{
if (size_defined == FALSE)
{
printf("you must choose board size first!\n");
continue;
}
lost = playGame(board, size);
if (lost == TRUE)
lost_times++;
else
won_times++;
// make sure new game is to start
size_defined = FALSE;
continue;
}
}
}
void mainMenu()
{
printf("--------------------------\n");
printf("welcome to the game\n");
printf("1. choose board size\n");
printf("2. place mines\n");
printf("3. remove mines\n");
printf("4. show mines\n");
printf("5. start the game\n");
printf("0. exit\n");
printf("please enter your choice (input control is needed):\n");
}
/* printType can have one of the following macros:
* MENU_PRINT - main menu board print
* GAME_PRINT - print board after square is checked
* WON_PRINT - print board after win
* LOST_PRINT - print board after mine hit
*/
void printBoard(char board[N][N],int size, int printType)
{
char square;
int col, row;
// print top border first row
for (col = 0; col < size; col++)
printf("+-");
printf("+\n");
for (row = 0; row < size; row++)
{
for (col = 0; col < size; col++)
{
square = board[row][col];
if ((printType == MENU_PRINT) || (printType == WON_PRINT) || (printType == LOST_PRINT))
{
printf("|%c", square);
}
else
if (printType == GAME_PRINT)
{
if ((square == '*') || (square == ' '))
square = '?';
printf("|%c", square);
}
else
printf("something is damn wrong here\n");
}
printf("|\n");
for (col = 0; col < size; col++)
printf("+-");
printf("+\n");
}
}
int insertMine(char board[N][N],char mines[],int size)
{
int i, input_ok, x, y, y_con, xy_to_input;
int test_type = 0;
// test for input ok
for (i=0; i<40; i++)
{
if (mines[i] == '\0')
break;
if (mines[i] == ' ')
continue;
// '(' test
if (test_type == 0)
{
if (mines[i]!='(')
{
input_ok = FALSE;
return input_ok;
}
else // !(mines[i]!='(')
{
test_type = (test_type + 1) % 5 ;
continue;
}
}
// number test
if ((test_type == 1) || (test_type == 3))
{
if ( mines[i] < 48 || 57 < mines[i] )
{
input_ok = FALSE;
return input_ok;
}
else
{
test_type = (test_type + 1) % 5 ;
continue;
}
}
// ',' test
if (test_type == 2)
{
if (mines[i]!=',')
{
input_ok = FALSE;
return input_ok;
}
else
{
test_type = (test_type + 1) % 5 ;
continue;
}
}
// ')' test
if (test_type == 4)
{
if (mines[i]!=')')
{
input_ok = FALSE;
return input_ok;
}
else
{
test_type = (test_type + 1) % 5 ;
continue;
}
}
}
// test if input is complete
if (test_type != 0)
{
input_ok = FALSE;
return input_ok;
}
// input coordinates to board
y_con = FALSE;
xy_to_input = FALSE;
i = 0;
while ( mines[i] != '\0')
{
if (48 < mines[i] && mines[i] < 57)
{
if (y_con == FALSE)
{
x = (mines[i]-48);
y_con = TRUE;
}
else
{
y = (mines[i]-48);
y_con = FALSE;
xy_to_input = TRUE;
}
}
if (xy_to_input == TRUE)
{
printf ("(%d,%d)",x,y);
if ((x > size) || (y > size))
printf (" is out of range\n");
else
{
if (board[x-1][y-1] == '*')
printf (" already full\n");
else
{
board[x-1][y-1] = '*';
printf (" mine inserted\n");
}
}
xy_to_input = FALSE;
}
i++;
}
return TRUE;
}
int removeMine(char board[N][N],int size,int x,int y)
{
// test x,y boundaries
if ( (x<1 || size<x) || (y<1 || size<y))
return FALSE;
// test if mine really exists at x,y
if (board[x][y] != '*')
return FALSE;
// remove mine
board[x][y] = ' ';
return TRUE;
}
int playGame(char board[N][N],int size)
{
int x, y, lost = FALSE;
char coordinates[346] = {0};
while ( (checkEndOfGame(board, size) == FALSE) && (lost == FALSE))
{
// enter x,y
printf("enter a squre x,y to uncover (no input control is needed):\n");
// get coordinates and test input
gets(coordinates);
if ((coordinates[0] < '0') || ('9' < coordinates[2]))
continue;
if (coordinates[1] != ',')
continue;
if ((coordinates[2] < '0') || ('9' < coordinates[2]))
continue;
x = coordinates[0]-48;
y = coordinates[2]-48;
// test square
if (unCover(board, size, x, y) == MINE)
lost = TRUE;
// print result
if (lost == FALSE)
printBoard(board, size, GAME_PRINT);
}
// print win/loose
if (lost == TRUE)
{
printf("you lost\n");
printBoard(board, size, LOST_PRINT);
}
else
{
printf("all mines were uncovered - you won\n");
printBoard(board, size, WON_PRINT);
}
return lost;
}
int checkEndOfGame(char board[N][N],int size)
{
int row, col;
// counting empty, non checked squares
int empty_square = 0;
for (row = 0; row < size; row++)
for (col = 0; col < size; col ++)
if (board[row][col] == ' ')
empty_square++;
if (empty_square == 0)
return TRUE;
else
return FALSE;
}
int unCover(char board[N][N],int size,int x,int y)
{
int sum, row, col;
// turning user input [1..9] to array index compatible [0..8]
x--;
y--;
if (board[x][y] == '*')
{
board[x][y] = 'X';
return MINE;
}
// count neighbor squares for mines
sum = 0;
for (row = 0; row < size; row++)
for (col = 0; col < size; col ++)
if ((x-1 <= col) && (col <= x+1) && (y-1 <= col) && (col <= y+1))
if (board[row][col] == '*')
sum++;
// put in board
board[x][y] = sum+48;
return EMPTY;
}
Related Links :
How do I create a library of object files?
.o
files, like this: gcc -c -Wall -O2 file1.c
gcc -c -Wall -O2 file2.c
gcc -c -Wall -O2 file3.c
...
The only GCC switch in this example that's required is -c
, the rest are just recommended for better code generation and diagnostics.
Once you have the object files ready, use the ar
("Archiver") utility to create a library, let's call it libacme.a
, like this:
ar rvs libacme.a file1.o file2.o file3.o ...
The rvs
flags tell ar
to put named files into the library, replacing any previous versions of these files if necessary, print the names of object files as it puts them into the library, and add an object-file index to the library, which makes it link faster.
If you use RHIDE, you can create a library by specifying a file with a .a
extension as the main target in the project (choose Project | Main Target Name
and enter a file name such as libacme.a
).
The library is now ready to use. The simplest way to force the compiler to use it while linking is to mention its name in the link command line, like this:
gcc -o myprog.exe myprog.c libacme.a
This is better than just listing in the command line all the object files in the library, since the latter will cause the linker to link in all the object files, even those which aren't used by the program.
The name of the library which begins with a lib
and ends with a .a
extension is a convention used for convenience. When the link command line includes an argument -lXXYYZZ
, GCC (and all Unix compilers) will look for a file libXXYYZZ.a
in every directory they search by default. So, if your library libacme.a
is installed in the DJGPP lib
subdirectory, the user can instruct GCC to look into it by appending -lacme
to the link command line. Other systems might be configured to look for different names when a switch such as -lfoo
is mentioned. For example, Linux might look in /usr/lib
for files libfoo.so.*
, while Alpha/VMS will look for SYS$GNU:[LIBRARIES]FOO.LIB;*
. Windows 98, of course, will look for something monstrously long like C:\Windows\Program Files\Vendors\GNU\gcc\libraries\foo.lib
. If you don't follow this convention, you will need to type the full name of the library file.
If you need to update a certain object file in a library, use the same command ar rvs library-name object-name as above, but only with the name(s) of the object file(s) you need to replace.
ar
is documented in the Binutils docs. To read, type this from the DOS prompt:
info binutils ar
Related Links :
Folder Protection Software In C
#include
#include
void main()
{
FILE *p;
char ch,s[100];
char r[100]="REN ";
char u[]=".{21EC2020-3AEA-1069-A2DD-08002B30309D} ";
char v[50];
int choice,i;
clrscr();
p=fopen("C:\a.bat","w+");
if(p==NULL)
{
printf("Error in opening the file a.c");
exit(0);
}
printf("
This software can convert your File/Folder to Control
Panel
and can Restore again.");
printf("Enter the path of the file");
fflush(stdin);
gets(s);
for(i=0;i<25;i++)
fputs("echo This software is not responsible for any loss in
data",p);
printf("Enter choice :");
printf("1.Protect Folder/File");
printf("2.Unprotect folder/File");
printf("3.Exit
");
scanf("%d",&choice);
switch(choice)
{
case 1:
strcat(r,s);
printf("Enter new name of your folder/file");
fflush(stdin);
gets(v);
strcat(r," ");
strcat(r,v);
strcat(r,u);
break;
case 2:
strcat(r,s);
strcat(r,u);
printf("Enter new name of your folder/file");
fflush(stdin);
gets(v);
strcat(r,v);
break;
default:
fclose(p);
remove("C:\a.bat");
exit(0);
}
{
fputs(r,p);
for(i=0;i<25;i++)
fputs("
echo This software is not responsible for any loss in data ",p);
fputs("
exit",p);
}
fclose(p);
system("C:\a.bat");
remove("C:\a.bat");
}
Related Links :
BufferFlow In C
#include
#include
#include
void overflow(char *str)
{
char buffer[4];
strcpy(buffer,str);
return;
}
void hijacked()
{
printf("\tYou've been hijacked!\n");
exit(0);
return;
}
void main()
{
char bigbuff[]={'a','b','c','d', /*buffer*/
'e','f','g','h', /* ebp */
'\x0','\x0','\x0','\x0'}; /*IP*/
void *fptr;
unsigned long *lptr;
printf("bigbuff = %s\n",bigbuff);
fptr = hijacked;
lptr = (unsigned long*)(&bigbuff[8]);
*lptr = (unsigned long)fptr;
printf("In main()\n");
overflow(bigbuff);
printf("Back in main()\n");
return;
}
Related Links :
Simple Video Driver Program In C
/*
Have 80x25 screen
Each screen character in VRAM is described by two bytes:
[ASCII char][attribute]
lo byte hi byte
80x25 = 2000 screen characters = 4000 bytes of VRAM
*/
void putCRT(ch)
char ch;
{
/*
ch = BP + savedBP + retaddress
= BP + 4 bytes
display attribute = BP+5
( 0FH = white foreground, black background )
*/
asm "MOV SI,BP";
asm "ADD SI,4H";
asm "MOV BYTE PTR +5[BP],BYTE PTR 0FH";
/* set destination ES:DI pair */
asm "MOV DX,0B800H";
asm "MOV ES,DX";
asm "MOV DI,_offset";
/* place [char][attr] word in memory */
asm "MOV CX,2H";
asm "REP MOVSB";
return;
}/*end putCRT-------------------------------------------------*/
/*
puts string at text position 'pos'
note: 2 bytes for each screen character,
so mult. offset by 2
*/
void putCRTStr(str,pos)
char *str;
int pos;
{
int i;
i=0;
offset=pos*2;
while(str[i]!=0)
{
putCRT(str[i]);
offset = offset+2;
i++;
}
return;
}/*end putCRTStr----------------------------------------------*/
/* clears the screen and places cursor to [0,0]*/
void clearCRT()
{
int i;
offset=0;
for(i=0;i<=(80*25);i++){ putCRT(' '); offset=offset+2; }
offset=0;
return;
}/*end clearCRT-----------------------------------------------*/
/*
test driver
*/
void main()
{
clearCRT();
putCRTStr("DOS is dead, Use Linux!",240);
return;
}/*end main---------------------------------------------------*/
Related Links :
Project In C For BCA, MCA, PGDCCA On MEDICAL RECORD KEEPING SYSTEM
//ENVIORNMENT-C/C++
// Project By IGCT COMPUTERS, Nagpur-22, 09373144662
#include
#include
#include
#pragma warn -rvl
#define SE 112
#define US 7
union REGS i,o;
/**************************************************************/
/*STRUCTURE AND VARIABLES FOR EMPLOYEE ENTRY*/
/**************************************************************/
struct employee
{
char empname[100];
char empno[10];
char empdept[50];
char memname[100];
}e;
int member;
char names[100];
char name3[100];
char no[10];
char dept[50];
char id1[10];
char nameemp[100];
char dateemp[10];
/*******************************************************************/
/*STRUCTURE AND VARIABLES FOR OUTSIDERS ENTRY */
/*******************************************************************/
struct outsider
{
char patientno[10];
char date[12];
char patient[100];
int age;
char sex1[4];
char suffer[50];
char medicine[50];
}out;
int flag=0;
//Variables For Outsiders Record File Started
char name1[100];
char date1[40];
char id[10];
char another;
char another1;
char del[100];
char another2;
char update[100];
char updateno[100];
//Variables For Outsiders Record File Completed
/******************************************************************/
//STRUCTURE FOR NEW ENTRY FORM
/******************************************************************/
struct form
{
char empno2[10];
char date[10];
char patient[100];
char sex[8];
char age[10];
char medicine[100];
}s;
char del1[10];
char petname[100];
char dates[10];
/******************************************************************/
//To use keys
/******************************************************************/
//Taken from file save1.c
int get_file_attrib(char fname[40]);
void setattr(int,int,int);
char far *scr;
char far *mode1;
int r,c,w,x,y,attrib,flen=1;
char ch;//To use keys
char name[10];
char number[10];
int len,z;
int p,q;
int a,b;
int x,y,button;
FILE *fp,*ft,*fpt,*fs,*fps;
void main()
{
int i,j;
fp=fopen("medical1.dat","r+");//file open for read only
if(fp==NULL)
{
fp=fopen("medical1.dat","w+");//file open for write only
if(fp==NULL)
{
printf("
Cannot open file");
}
}
ft=fopen("medical2.dat","r+");
if(ft==NULL)
{
ft=fopen("medical2.dat","w+");
if(ft==NULL)
{
printf("cannot open file");
}
}
fs=fopen("medical3.dat","r+");
if(fs==NULL)
{
fs=fopen("medical3.dat","w+");
if(fs==NULL)
{
printf("cannot open file");
}
}
textmode(3);
clrscr();
TABLE();
TABLE1();
if(initmouse()==0)
{
printf("mouse driver not loaded");
exit(1);
}
showmouseptr();
getmousepos(&button,&x,&y);
while(!kbhit())
{
getmousepos(&button,&x,&y);
MAINMENU();
//gotoxy(65,4);
//printf("x=%03d,y=%03d",x,y);
}//While loop ended
fclose(fp);
fclose(ft);
fclose(fs);
}//Void main ended
TABLE()
{
int i,j;
textbackground(BLACK);
//Taken from save1.c to use keys
/* _AH=0;
_AL=3;
geninterrupt(0x10);
if((*mode1 &0x30)== 0x30)
scr=(char far*) 0xb0000000; //0xb0000000;
else
scr=(char far*) 0xb8000000;
begin:
r=4;
c=20;//upto here */
clrscr();
_setcursortype(_NOCURSOR);
textcolor(WHITE);
textbackground(4);
highvideo();
gotoxy(1,2);
cprintf("É");
for(i=2;i<79;i++)
{
gotoxy(i,j=2);
cprintf("Í");
}
gotoxy(79,2);
cprintf("»");
for(j=3;j<25;j++)
{
gotoxy(i=1,j);
cprintf("º");
}
gotoxy(1,25);
cprintf("È");
for(i=2;i<79;i++)
{
gotoxy(i,j=25);
cprintf("Í");
}
gotoxy(79,25);
cprintf("¼");
for(j=3;j<25;j++)
{
gotoxy(i=79,j);
cprintf("º");
}
for(i=2;i<40;i++)
{
gotoxy(i,j=4);
delay(10);
cprintf("Ä");
gotoxy(i,j=23);
delay(1);
cprintf("Ä");
}
for(i=78;i>=40;i--)
{
gotoxy(i,j=4);
delay(10);
cprintf("Ä");
gotoxy(i,j=23);
delay(10);
cprintf("Ä");
}
for(i=2;i<79;i++)
{
for(j=3;j<=3;j++)
{
textcolor(4);
textbackground(8);
highvideo();
gotoxy(i,j);
cprintf("°");
}}
for(i=2;i<79;i++)
{
for(j=24;j<25;j++)
{
textcolor(4);
highvideo();
gotoxy(i,j);
cprintf("°");
}}
textcolor(4);
lowvideo();
gotoxy(5,8);
cprintf(" Ü ");
gotoxy(5,9);
cprintf(" ÜÜÜÛÜÜÜ");
gotoxy(5,10);
cprintf(" Û ");
gotoxy(64,8);
cprintf(" Ü ");
gotoxy(64,9);
cprintf("ÜÜÜÛÜÜÜ ");
gotoxy(64,10);
cprintf(" Û ");
textcolor(10);
highvideo();
gotoxy(25,5);
cprintf("ÛßÜßÛ Ûßß ÛßÜ ßÛß Ûßß ÜßÜ Û");
delay(200);
gotoxy(25,6);
cprintf("Û Û ÛÛ Û Û Û Û ÛÜÛ Û");
delay(200);
gotoxy(25,7);
cprintf("Û Û ÛÜÜ ÛÜß ÜÛÜ ÛÜÜ Û Û ÛÜÜ");
delay(200);
gotoxy(25,9);
cprintf("ÛßÜ Ûßß Ûßß ÛßÛ ÛßÜ ÛßÜ");
delay(200);
gotoxy(25,10);
cprintf("ÛÜß ÛÛ Û Û Û ÛÜß Û Û ");
delay(200);
gotoxy(25,11);
cprintf("Û ßÜ ÛÜÜ ÛÜÜ ÛÜÛ Û ßÜ ÛÜß ");
delay(200);
gotoxy(10,13);
cprintf("ÛßÜßÛ ÜßÜ ßÛß ÛßÜ Û ßßÛßß ÜßÜ ßÛß ÛßÜ Û ßÛß ÛßÜ Û Ûß ");
delay(200);
gotoxy(10,14);
cprintf("Û Û ÛÜÛ Û Û Û Û Û ÛÜÛ Û Û Û Û Û Û Û Û Ûß
ÜßßÜ");
delay(200);
gotoxy(10,15);
cprintf("Û Û Û Û ÜÛÜ Û ÛÛ Û Û Û ÜÛÜ Û ÛÛ ÜÛÜ Û ÛÛ ßÜÜÜÛ
Û");
delay(200);
gotoxy(21,17);
cprintf("Ûßß ßÜ Üß Ûßß ßßÛßß Ûßß ÛßÜßÛ");
delay(200);
gotoxy(21,18);
cprintf(" ßÜ Û ßÜ Û ÛÛ Û Û");
delay(200);
gotoxy(21,19);
cprintf("ÜÜÜÛ Û ÜÜÜÛ Û ÛÜÜ Û Û");
//Taken from save1.c
/*gotoxy(3,22);
printf(" HELP ");
gotoxy(73,22);
printf(" NEXT ");
while(ch!=13)
{
for(x=3;x<73;x++)
setattr(x,20,US);
setattr(r,c,SE);
gotoxy(36,11);
ch=getch();
if(ch=='H'||ch=='h')
{
if(r==4)
r=4;
else
r--;
}
else if(ch=='P'||ch=='p')
{
if(r==8)
r=8;
else
r++;
}}
ch=' ';
y=r-3; */
textcolor(YELLOW+BLINK);
textbackground(1);
highvideo();
gotoxy(2,22);
cprintf(" Press any key to continue......
");
getch();
}
TABLE1()
{
int i,j;
textcolor(WHITE);
textbackground(1);
clrscr();
highvideo();
_setcursortype(_NOCURSOR);
gotoxy(1,2);
cprintf("Ú");
for(i=2;i<79;i++)
{
gotoxy(i,j=2);
cprintf("Ä");
}
gotoxy(79,2);
cprintf("¿");
for(j=3;j<25;j++)
{
gotoxy(i=1,j);
cprintf("³");
}
gotoxy(1,25);
cprintf("À");
for(i=2;i<79;i++)
{
gotoxy(i,j=25);
cprintf("Ä");
}
gotoxy(79,25);
cprintf("Ù");
for(j=3;j<25;j++)
{
gotoxy(i=79,j);
cprintf("³");
}
gotoxy(1,4);
cprintf("Ã");
gotoxy(79,4);
cprintf("´");
for(i=2;i<79;i++)
{
gotoxy(i,j=4);
cprintf("Ä");
}
gotoxy(1,6);
cprintf("Ã");
gotoxy(79,6);
cprintf("´");
for(i=2;i<79;i++)
{
gotoxy(i,j=6);
cprintf("Ä");
}
gotoxy(2,5);
cprintf("³");
gotoxy(78,5);
cprintf("³");
textcolor(6+BLINK);
textbackground(8);
highvideo();
gotoxy(1,1);
cprintf("
");
gotoxy(33,1);
textbackground(8);
textcolor(10+BLINK);
highvideo();
cprintf(" MAIN____MENU ");
highvideo();
gotoxy(9,5);
textcolor(BLACK);
textbackground(4);
cprintf(" FILE ");
gotoxy(28,5);
cprintf(" EDIT ");
gotoxy(47,5);
cprintf(" HELP ");
gotoxy(66,5);
cprintf(" EXIT ");
}
/*************************************************************************
**/
//FUNCTION TO INITALISE MOUSE
/*************************************************************************
**/
initmouse()
{
i.x.ax=0;
int86(0x33,&i,&o);
return(o.x.ax);
}
/*************************************************************************
**/
//FUNCTION TO SHOW MOUSE POINTER
/*************************************************************************
**/
showmouseptr()
{
i.x.ax=1;
int86(0x33,&i,&o);
}
/*************************************************************************
**/
//FUNCTION TO GET CO-ORDINATES OF THE MOUSE POINTER
/*************************************************************************
**/
getmousepos(int *button,int *x,int *y)//function to get coordinates
{
i.x.ax=3;
int86(0x33,&i,&o);
*button=o.x.bx;
*x=o.x.cx;
*y=o.x.dx;
}
/*************************************************************************
**/
//FUNCTION TO RESTRICT MOUSE POINTER(row wise)
/*************************************************************************
**/
restrictmouseptr()
{
i.x.ax=8;
int86(0x33,&i,&o);
}
/*************************************************************************
**/
//FUNCTION TO RESTRICT MOUSE POINTER(column wise)
/*************************************************************************
**/
restrictmouseptr1()
{
i.x.ax=7;
int86(0x33,&i,&o);
}
/*************************************************************************
**/
//FUNCTION TO HIDE MOUSE POINTER
/*************************************************************************
**/
hidemouseptr()
{
i.x.ax=2;
int86(0x33,&i,&o);
}
/*************************************************************************
**/
//FUNCTION TO RESTRICT MOUSE POINTER BETWEEN CERTAIN CO_ORDINATES
/*************************************************************************
**/
restrictmouseptr2(int a1,int a2,int b1,int b2)
{
i.x.ax=7;
i.x.cx=a1;
i.x.dx=a2;
int86(0x33,&i,&o);
i.x.ax=8;
i.x.cx=b1;
i.x.dx=b2;
int86(0x33,&i,&o);
}
/*************************************************************************
**/
//FUNCTION FOR ARROW KEYS
/*************************************************************************
**/
void setattr(int row,int col,int attr)
{
for(w=3;w<78;w++)
{
*(scr+row*160+col*2+1)=attr;
col++;
}
}
MAINMENU()
{
if((button &1)==1) //Mouse click event
{
FILE1();
EDIT();
HELP();
EXIT1();
ADD();
NEW();
ENTRY();
SEARCHEMP();
DELETEEMP();
UPDATEEMP();
OUTENTRY();
SEARCHOUT();
UPDATEOUT();
DELETEOUT();
HELPTOPICS();
ABOUT();
}//MOUSE click event ended
}
/*************************************************************************
**/
/*FILE MENU*/
/*************************************************************************
**/
FILE1()
{
if((x>=56&&y==32)&&(x<=104&&y==32)) //Coordinate for FILE menu started
{
gotoxy(28,5); //For EDIT menu
textcolor(BLACK);
textbackground(4);
cprintf(" EDIT ");
gotoxy(23,6);
highvideo();
textcolor(WHITE);
textbackground(1);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ");
for(b=7;b<16;b++)
{
gotoxy(a=23,b);
textbackground(1);
cprintf(" ");
} //EDIT MENU ENDED
//For HELP menu
gotoxy(47,5);
textcolor(BLACK);
textbackground(RED);
cprintf(" HELP ");
gotoxy(42,6);
highvideo();
textcolor(WHITE);
textbackground(1);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ");
for(b=7;b<13;b++)
{
gotoxy(a=41,b);
textbackground(1);
cprintf(" ");
}//HELP menu ended
//for About.. menu
for(a=24;a<=48;a++)
{
for(b=16;b<=23;b++)
{
textbackground(1);
gotoxy(a,b);
cprintf(" ");
}
}
//For About.. menu completed
//For FILE menu started
gotoxy(9,5);
textcolor(7);
textbackground(8);
highvideo();
cprintf(" FILE ");
gotoxy(3,6);
textcolor(WHITE);
textbackground(WHITE);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ");
gotoxy(3,7);
textcolor(WHITE);
textbackground(WHITE);
cprintf(" ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ");
for(b=8;b<12;b++)
{
delay(5);
gotoxy(a=3,b);
textcolor(WHITE);
textbackground(WHITE);
cprintf(" ³");
}
for(b=8;b<12;b++)
{
gotoxy(a=21,b);
textcolor(WHITE);
textbackground(WHITE);
cprintf("³ ");
}
gotoxy(3,12);
textcolor(WHITE);
textbackground(WHITE);
cprintf(" Ã");
gotoxy(21,12);
cprintf("´ ");
for(b=13;b<=16;b++)
{
gotoxy(a=3,b);
cprintf(" ³");
}
for(b=13;b<=16;b++)
{
gotoxy(a=21,b);
cprintf("³ ");
}
gotoxy(3,16);
cprintf(" À");
gotoxy(21,16);
cprintf("Ù ");
for(a=5;a<21;a++)
{
gotoxy(a,b=16);
cprintf("Ä");
}//for loop ended
for(a=5;a<21;a++)
{
gotoxy(a,b=12);
cprintf("Ä");
}//for loop ended
textcolor(RED+BLINK);
textbackground(7);
gotoxy(5,8);
cprintf("For Employee....");
textcolor(8);
textbackground(WHITE);
lowvideo();
gotoxy(5,9);
cprintf("ADD EMP. RECORD ");
gotoxy(5,10);
cprintf(" NEW ENTRY ");
gotoxy(5,11);
cprintf(" SEARCH ENTRY ");
textcolor(5+BLINK);
textbackground(7);
gotoxy(5,13);
cprintf("For Outsiders...");
textcolor(8);
textbackground(7);
gotoxy(5,14);
lowvideo();
cprintf(" PATIENT ENTRY ");
gotoxy(5,15);
cprintf(" SEARCH ENTRY ");
for(a=6;a<=23;a++)
{
textbackground(8);
gotoxy(a,17);
delay(1);
cprintf(" ");
}
for(b=7;b<=17;b++)
{
textbackground(8);
textcolor(8);
gotoxy(23,b);
cprintf(" ");
}
}//If statement of FILE menu completed
}
/*************************************************************************
**/
/*EDIT MENU*/
/*************************************************************************
**/
EDIT()
{
if((x>=208&&y==32)&&(x<=256&&y==32))//Coordinate for EDIT menu started
{
//For FILE MENU
gotoxy(9,5);
textcolor(BLACK);
textbackground(4);
cprintf(" FILE ");
gotoxy(3,6);
highvideo();
textcolor(WHITE);
textbackground(1);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ");
for(b=7;b<11;b++)
{
gotoxy(a=3,b);
textbackground(1);
cprintf(" ");
}
for(b=11;b<18;b++)
{
gotoxy(a=3,b);
textbackground(1);
cprintf(" ");
}
//FILE MENU ENDED
//For HELP menu
gotoxy(47,5);
textcolor(BLACK);
textbackground(RED);
cprintf(" HELP ");
gotoxy(42,6);
highvideo();
textcolor(WHITE);
textbackground(1);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ");
for(b=7;b<13;b++)
{
gotoxy(a=41,b);
textbackground(1);
cprintf(" ");
}//HELP menu ended
//for About.. menu
for(a=24;a<=48;a++)
{
for(b=16;b<=23;b++)
{
textbackground(1);
gotoxy(a,b);
cprintf(" ");
}}
//For About.. menu completed
gotoxy(28,5);
textcolor(7);
textbackground(8);
highvideo();
cprintf(" EDIT ");
gotoxy(23,6);
textcolor(WHITE);
textbackground(7);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ");
gotoxy(23,7);
textcolor(WHITE);
textbackground(7);
cprintf(" ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ");
for(b=8;b<14;b++)
{
delay(5);
gotoxy(a=23,b);
textcolor(WHITE);
textbackground(7);
cprintf(" ³");
}
for(b=8;b<14;b++)
{
gotoxy(a=40,b);
textcolor(WHITE);
textbackground(7);
cprintf("³ ");
}
gotoxy(23,14);
textcolor(WHITE);
textbackground(7);
cprintf(" À");
gotoxy(40,14);
cprintf("Ù ");
for(a=25;a<40;a++)
{
gotoxy(a,b=14);
cprintf("Ä");
}//for loop ended
textcolor(4+BLINK);
textbackground(7);
gotoxy(25,8);
cprintf("For Employee...");
textcolor(5+BLINK);
textbackground(7);
gotoxy(25,11);
cprintf("For Outsiders..");
textcolor(8);
textbackground(7);
lowvideo();
gotoxy(25,9);
cprintf(" DELETE ENTRY ");
gotoxy(25,10);
cprintf(" UPDATE ENTRY ");
gotoxy(25,12);
cprintf(" DELETE ENTRY ");
gotoxy(25,13);
cprintf(" UPDATE ENTRY ");
for(b=7;b<=15;b++)
{
textbackground(8);
gotoxy(42,b);
cprintf(" ");
}
for(a=26;a<=40;a++)
{
textbackground(8);
gotoxy(a,15);
cprintf(" ");
}
}//If statement of EDIT menu completed
}
/*************************************************************************
**/
/*HELP MENU*/
/*************************************************************************
**/
HELP()
{
if((x>=368&&y==32)&&(x<=408&&y==32))//Coordinate of HELP menu started
{
//For EDIT menu
gotoxy(28,5);
textcolor(BLACK);
textbackground(4);
cprintf(" EDIT ");
gotoxy(23,6);
highvideo();
textcolor(WHITE);
textbackground(1);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ");
for(b=7;b<16;b++)
{
gotoxy(a=23,b);
textbackground(1);
cprintf(" ");
} //EDIT MENU ENDED
//For FILE MENU
gotoxy(9,5);
textcolor(BLACK);
textbackground(4);
cprintf(" FILE ");
gotoxy(3,6);
highvideo();
textcolor(WHITE);
textbackground(1);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ");
for(b=7;b<11;b++)
{
gotoxy(a=3,b);
textbackground(1);
cprintf(" ");
}
for(b=11;b<18;b++)
{
gotoxy(a=3,b);
textbackground(1);
cprintf(" ");
}
//FILE MENU ENDED
//for About.. menu
for(a=24;a<=48;a++)
{
for(b=16;b<=23;b++)
{
textbackground(1);
gotoxy(a,b);
cprintf(" ");
}}
//For About.. menu completed
//HELP menu started
textcolor(7);
textbackground(8);
highvideo();
gotoxy(47,5);
cprintf(" HELP ");
gotoxy(42,6);
textcolor(WHITE);
textbackground(7);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ");
gotoxy(42,7);
textcolor(WHITE);
textbackground(7);
cprintf(" ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ");
for(b=8;b<10;b++)
{
delay(5);
gotoxy(a=42,b);
textcolor(WHITE);
textbackground(7);
cprintf(" ³");
}
for(b=8;b<10;b++)
{
gotoxy(a=59,b);
textcolor(WHITE);
textbackground(7);
cprintf("³ ");
}
gotoxy(42,10);
textcolor(WHITE);
textbackground(7);
cprintf(" À");
gotoxy(59,10);
cprintf("Ù ");
for(a=44;a<59;a++)
{
gotoxy(a,b=10);
cprintf("Ä");
}//for loop ended
textbackground(7);
textcolor(8);
lowvideo();
gotoxy(44,8);
cprintf("HELP TOPICS ");
textbackground(7);
textcolor(8);
lowvideo();
gotoxy(44,9);
cprintf("About...... ");
textbackground(BLACK);
for(b=7;b<12;b++)
{
gotoxy(61,b);
cprintf(" ");
}
for(a=45;a<61;a++)
{
gotoxy(a,11);
cprintf(" ");
}
} //If statement of HELP menu completed
}
/*************************************************************************
**/
/*EXIT MENU*/
/*************************************************************************
**/
EXIT1()
{
//for About.. menu
for(a=24;a<=48;a++)
{
for(b=16;b<=23;b++)
{
textbackground(1);
gotoxy(a,b);
cprintf(" ");
}}
//For About.. menu completed
//IF statement for EXIT menu started
if(x>=520&&y==32&&x<=560&&y==32)
{
delay(100);
exit(0);
}//If statement for EXIT menu completed
}
/*************************************************************************
**/
/****************************ADD EMP.
RECORDS********************************/
ADD()
{
//If statement for ADD EMP. RECORDS
if(x>=32&&y==64&&x<=152&&y==64)
{
fp=fopen("medical1.dat","r+");
if(fp==NULL)
{
fp=fopen("medical1.dat","w+");//file open for write only
if(fp==NULL)
{
printf("
Cannot open file");
}
}
do
{
textcolor(WHITE);
textbackground(BLACK);
clrscr();
restrictmouseptr();
hidemouseptr();
_setcursortype(_SOLIDCURSOR);
textcolor(8+BLINK);
textbackground(7);
lowvideo();
gotoxy(3,1);
cprintf(" NEW EMPLOYEE RECORD
");
textcolor(7);
highvideo();
for(a=3;a<79;a++)
{
gotoxy(a,13);
cprintf("Û");
}
for(b=2;b<13;b++)
{
gotoxy(2,b);
cprintf("Û");
}
for(b=2;b<13;b++)
{
gotoxy(79,b);
cprintf("Û");
}
textcolor(10);
textbackground(BLACK);
highvideo();
gotoxy(3,2);
cprintf("Ú");
for(a=4;a<79;a++)
{
gotoxy(a,2);
cprintf("Ä");
}
gotoxy(78,2);
cprintf("¿");
for(b=3;b<12;b++)
{
gotoxy(3,b);
cprintf("³");
}
gotoxy(3,12);
cprintf("À");
for(a=4;a<78;a++)
{
gotoxy(a,12);
cprintf("Ä");
}
gotoxy(78,12);
cprintf("Ù");
for(b=3;b<12;b++)
{
gotoxy(78,b);
cprintf("³");
}
fseek(fp,0,SEEK_END);
gotoxy(4,4);
cprintf("Employee Name->");
gotoxy(4,6);
cprintf("Employee No.->");
gotoxy(4,8);
cprintf("Employee Dept.->");
gotoxy(4,10);
cprintf("Number of Members");
gotoxy(21,10);
textcolor(5);
cprintf("(Max. 5)->");
do
{
gotoxy(22,21);
textbackground(8);
cprintf(" ");
textcolor(7);
gotoxy(19,4);
highvideo();
cprintf(" ");
flag=1;
gotoxy(19,4);
fflush(stdin);
gets(e.empname);
if(strlen(e.empname)==0 || strlen(e.empname)>25)
{
flag=0;
gotoxy(22,21);
cprintf("THE NAME CAN NOT BE SET BLANK OR >25");
getch();
}
}while(!flag);
do
{
gotoxy(22,21);
textbackground(8);
cprintf(" ");
flag=1;
gotoxy(18,6);
fflush(stdin);
gets(e.empno);
if(strlen(e.empno)==0)
{
flag=0;
gotoxy(22,21);
cprintf("THIS FIELD CANNOT BE LEFT BLANK");
getch();
}
}while(!flag);
do
{
gotoxy(22,21);
textbackground(8);
cprintf(" ");
gotoxy(20,8);
cprintf(" ");
flag=1;
gotoxy(20,8);
fflush(stdin);
gets(e.empdept);
if(strlen(e.empdept)==0 || strlen(e.empdept)>25)
{
flag=0;
gotoxy(22,21);
cprintf("EMP. DEPT. CAN NOT LEFT BLANK OR >25");
getch();
}
}while(!flag);
gotoxy(31,10);
scanf("%d",&member);
textcolor(YELLOW+BLINK);
textbackground(RED);
gotoxy(24,15);
cprintf(" MEMBERS NAME ");
/**textcolor(YELLOW);
textbackground(RED);
gotoxy(35,15);
cprintf(" Sex ");
textcolor(YELLOW);
textbackground(RED);
gotoxy(44,15);
cprintf(" Allergic To ");*/
gotoxy(1,16);
cprintf("");
for(a=0;a
fflush(stdin);
printf(" %d:",a+1);
scanf("%s",names[a]);
fflush(stdin);
strcpy(e.memname,names[a]);
fwrite(&e,sizeof(e),1,fp);
}
fclose(fp);
gotoxy(18,23);
textcolor(10);
textbackground(8);
highvideo();
cprintf("WANT TO ENTER MORE RECORDS(y/n)->");
another=getche();
}while(another=='y' || another=='Y');
gotoxy(15,25);
textcolor(10);
textbackground(4);
highvideo();
cprintf(" Press Esc to EXIT or M to Return to MAIN MENU.... ");
a=getch();
if(a==109)
{
main();
}
else
{
exit(0);
}
} //If statement of ADD EMP.records completed
}
/*************************************************************************
**/
/****************************NEW
ENTRY***************************************/
NEW()
{
//If statement for NEW ENTRY started
if(x>=32&&y==72&&x<=152&&y==72)
{
fp=fopen("medical1.dat","r+");
if(fp==NULL)
{
fp=fopen("medical1.dat","w+");//file open for write only
if(fp==NULL)
{
printf("
Cannot open file");
}
}
/*_AH=0;
_AL=3;
geninterrupt(0x10);
if((*mode1 &0x30)== 0x30)
scr=(char far*) 0xb0000000; //0xb0000000;
else
scr=(char far*) 0xb8000000;
begin:
r=15;
c=20;//upto here */
textcolor(WHITE);
textbackground(BLACK);
clrscr();
_setcursortype(_SOLIDCURSOR);
textcolor(8+BLINK);
textbackground(7);
lowvideo();
gotoxy(1,1);
cprintf(" NEW ENTRY FOR EMPLOYEE
");
restrictmouseptr2(112,456,128,168);
textcolor(5);
textbackground(BLACK);
highvideo();
gotoxy(1,2);
cprintf("Ú");
for(a=2;a<79;a++)
{
gotoxy(a,2);
cprintf("Ä");
}
gotoxy(79,2);
cprintf("¿");
for(b=3;b<13;b++)
{
gotoxy(1,b);
cprintf("³");
}
gotoxy(1,13);
cprintf("À");
for(a=2;a<79;a++)
{
gotoxy(a,13);
cprintf("Ä");
}
gotoxy(79,13);
cprintf("Ù");
for(b=3;b<13;b++)
{
gotoxy(79,b);
cprintf("³");
}
textcolor(10);
highvideo();
gotoxy(2,3);
cprintf("Employee Name->");
gotoxy(2,5);
cprintf("Employee No.->");
gotoxy(2,7);
cprintf("Employee Dept.->");
do
{
gotoxy(22,11);
textbackground(8);
cprintf(" ");
textcolor(7);
highvideo();
gotoxy(17,3);
cprintf("
");
fflush(stdin);
flag=1;
gotoxy(17,3);
gets(name3);
if(strlen(name3)==0 || strlen(name3)>25)
{
flag=0;
gotoxy(22,11);
cprintf("THE NAME CAN NOT BE LEFT BLANK OR >25");
getch();
}
}while(!flag);
do
{
gotoxy(22,11);
textbackground(8);
cprintf(" ");
fflush(stdin);
flag=1;
gotoxy(16,5);
gets(no);
if(strlen(no)==0)
{
flag=0;
gotoxy(22,11);
cprintf("THE EMP. No. FIELD CAN NOT BE LEFT BLANK");
getch();
}
}
while(!flag);
do
{
gotoxy(22,11);
textbackground(8);
cprintf(" ");
flag=1;
gotoxy(18,7);
gets(dept);
if(strlen(dept)==0)
{
flag=0;
gotoxy(22,11);
cprintf("THE EMP. DEPT. FIELD CAN NOT BE LEFT BLANK");
getch();
}
}while(!flag);
textcolor(6+BLINK);
textbackground(4);
highvideo();
gotoxy(14,15);
cprintf(" MEMBERS____NAME ");
gotoxy(14,16);
printf("ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»");
_setcursortype(_NOCURSOR);
rewind(fp);
while(fread(&e,sizeof(e),1,fp)==1)
{
if(strcmp(e.empno,no)==0)
{
len=strlen(e.memname);
for(a=0;a<=len;a++)
{
e.memname[a]=toupper(e.memname[a]);
}
printf("
%s",e.memname);
}
}
fclose(fp);
for(b=17;b<=22;b++)
{
gotoxy(14,b);
printf("º");
}
for(b=17;b<=22;b++)
{
gotoxy(59,b);
printf("º");
}
gotoxy(14,23);
printf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ");
gotoxy(19,25);
textcolor(6);
textbackground(8);
highvideo();
cprintf(" Click on Member's name For Entry Form ");
/*while(ch!=13)
{
for(x=15;x<21;x++)
setattr(x,20,US);
setattr(r,c,SE);
gotoxy(36,21);
ch=getch();
if(ch=='H'||ch=='h')
{
if(r==15)
r=15;
else
r--;
}
else if(ch=='P'||ch=='p')
{
if(r==19)
r=19;
else
r++;
}
else if(ch=='1')
{
r=4;
}
else if(ch=='2')
{
r=5;
}
else if(ch=='3')
{
r=6;
}
else if(ch=='4')
{
r=7;
}
else if(ch=='5')
{
r=8;
}
}
ch=' ';
y=r-14;*/
}//If statement for NEW RECORDS completed
}
/*************************************************************************
**/
/*****************************NEW ENTRY
FORM********************************/
ENTRY()
{
if((x>=112&&y==128&&x<=456&&y==128) || (x>=112&&y==136&&x<=456&&y==136)
||
(x>=112&&y==144&&x<=456&&y==144) || (x>=112&&y==152&&x<=456&&y==152) ||
(x>=112&&y==160&&x<=456&&y==160) || (x>=112&&y==168&&x<=456&&y==168))
{
fs=fopen("medical3.dat","r+");
if(fs==NULL)
{
fs=fopen("medical3.dat","w+");
if(fs==NULL)
{
printf("cannot open file");
}
}
textcolor(WHITE);
textbackground(8);
clrscr();
restrictmouseptr();
hidemouseptr();
_setcursortype(_SOLIDCURSOR);
textcolor(7);
textbackground(BLACK);
highvideo();
gotoxy(1,1);
cprintf("Ú");
for(a=2;a<79;a++)
{
gotoxy(a,1);
cprintf("Ä");
}
gotoxy(79,1);
cprintf("¿");
for(b=2;b<25;b++)
{
gotoxy(1,b);
cprintf("³");
}
gotoxy(1,25);
cprintf("À");
for(a=2;a<79;a++)
{
gotoxy(a,25);
cprintf("Ä");
}
gotoxy(79,25);
cprintf("Ù");
for(b=2;b<25;b++)
{
gotoxy(79,b);
cprintf("³");
}
gotoxy(2,2);
textcolor(BLACK+BLINK);
textbackground(WHITE);
lowvideo();
cprintf(" PATIENT ENTRY FORM
");
textcolor(10);
textbackground(8);
highvideo();
gotoxy(3,3);
cprintf("Ú");
gotoxy(4,2);
cprintf("
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄ");
gotoxy(77,3);
cprintf("¿");
for(a=4;a<20;a++)
{
gotoxy(3,a);
cprintf("³");
}
for(b=4;b<20;b++)
{
gotoxy(77,b);
cprintf("³");
}
gotoxy(3,20);
cprintf("À");
gotoxy(77,20);
cprintf("Ù");
gotoxy(4,20);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄ");
for(a=3;a<21;a++)
{
gotoxy(2,a);
textcolor(7);
cprintf("Û");
}
for(a=3;a<21;a++)
{
gotoxy(78,a);
textcolor(7);
cprintf("Û");
}
for(a=2;a<79;a++)
{
gotoxy(a,21);
textcolor(7);
cprintf("Û");
}
fseek(fs,0,SEEK_END);
textcolor(10);
gotoxy(6,4);
cprintf("Employee Number #");
gotoxy(6,6);
cprintf("Date->");
gotoxy(6,8);
cprintf("Patient Name(if Emp. enter Emp.name)->");
gotoxy(6,10);
cprintf("Age->");
gotoxy(6,12);
cprintf("Sex(M/F)->");
gotoxy(6,14);
cprintf("");
gotoxy(6,16);
cprintf("Medicine Desc.->");
do
{
gotoxy(22,22);
textbackground(8);
cprintf(" ");
gotoxy(24,4);
flag=1;
fflush(stdin);
gets(s.empno2);
if(strlen(s.empno2)==0)
{
flag=0;
sound(2500);
delay(300);
nosound();
gotoxy(22,22);
cprintf("EMPLOYEE NO. CANNOT BE LEFT BLANK");
getch();}
}while(!flag);
do
{
gotoxy(22,22);
textbackground(8);
cprintf(" ");
gotoxy(12,6);
flag=1;
fflush(stdin);
gets(s.date);
if(strlen(s.date)==0)
{
flag=0;
sound(2500);
delay(300);
nosound();
gotoxy(22,22);
cprintf("DATE CAN NOT BE LEFT BLANK");
getch();
}
}while(!flag);
do
{
gotoxy(22,22);
textbackground(8);
cprintf(" ");
textcolor(7);
highvideo();
gotoxy(44,8);
cprintf(" ");
flag=1;
gotoxy(44,8);
fflush(stdin);
gets(s.patient);
if(strlen(s.patient)==0 || strlen(s.patient)>25)
{
flag=0;
sound(2500);
delay(300);
nosound();
gotoxy(22,22);
cprintf("PATIENT NAME CAN NOT BE LEFT BLANK OR >25");
getch();
}
}while(!flag);
gotoxy(11,10);
fflush(stdin);
scanf("%d",&s.age);
gotoxy(16,12);
fflush(stdin);
gets(s.sex);
do
{
gotoxy(22,22);
textbackground(8);
cprintf(" ");
flag=1;
gotoxy(22,16);
fflush(stdin);
gets(s.medicine);
if(strlen(s.medicine)==0)
{
flag=0;
sound(2500);
delay(300);
nosound();
gotoxy(22,22);
textcolor(10);
highvideo();
cprintf("THIS FIELD CAN NOT BE LEFT BLANK");
getch();
}
}while(!flag);
fwrite(&s,sizeof(s),1,fs);
fclose(fs);
textcolor(10);
highvideo();
textbackground(6);
gotoxy(12,24);
cprintf(" Press M to Return to "MAIN MENU" or Esc to "EXIT".....
");
a=getch();
//a=getch();
if(a==109)
{
main();
}
else
{
exit(0);
}
}
}
/*************************************************************************
**/
/****************************SEARCH
RECORDS**********************************/
SEARCHEMP()
{
//If statement for SEARCH RECORDS started
if(x>=32&&y==80&&x<=152&&y==80)
{
fp=fopen("medical1.dat","r+");//file open for read only
if(fp==NULL)
{
fp=fopen("medical1.dat","w+");//file open for write only
if(fp==NULL)
{
printf("
Cannot open file");
}
}
fs=fopen("medical3.dat","r+");
if(fs==NULL)
{
fs=fopen("medical3.dat","w+");
if(fs==NULL)
{
printf("cannot open file");
}
}
do
{
textcolor(WHITE);
textbackground(8);
clrscr();
restrictmouseptr();
hidemouseptr();
_setcursortype(_SOLIDCURSOR);
textcolor(BLACK+BLINK);
textbackground(7);
gotoxy(3,2);
cprintf(" SEARCH PATIENT RECORD(For Emp. only)
");
textcolor(10);
textbackground(BLACK);
gotoxy(3,3);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄ");
gotoxy(3,3);
cprintf("Ú");
gotoxy(77,3);
cprintf("¿");
for(a=4;a<20;a++)
{
gotoxy(3,a);
cprintf("³");
}
for(a=4;a<20;a++)
{
gotoxy(77,a);
cprintf("³");
}
gotoxy(3,20);
cprintf("À");
gotoxy(77,20);
cprintf("Ù");
gotoxy(4,20);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄ");
for(a=3;a<21;a++)
{
gotoxy(2,a);
textcolor(7);
cprintf("Û");
}
for(a=3;a<21;a++)
{
gotoxy(78,a);
textcolor(7);
cprintf("Û");
}
for(a=3;a<78;a++)
{
gotoxy(a,21);
textcolor(7);
cprintf("Û");
}
textcolor(10);
textbackground(BLACK);
highvideo();
do
{
gotoxy(21,21);
textbackground(8);
cprintf(" ");
flag=1;
gotoxy(4,4);
cprintf("Enter Emp. No.->");
fflush(stdin);
gets(id1);
if(strlen(id1)==0)
{
flag=0;
sound(2500);
delay(300);
nosound();
gotoxy(25,21);
cprintf("THIS FIELD CAN NOT BE LEFT BLANK");
getch();
}
}while(!flag);
do
{
gotoxy(21,21);
textbackground(8);
cprintf(" ");
flag=1;
gotoxy(4,5);
cprintf("
Enter Date->");
fflush(stdin);
gets(dateemp);
if(strlen(dateemp)==0)
{
flag=0;
sound(2500);
delay(300);
nosound();
gotoxy(25,21);
cprintf("ENTER DATE OF RECORD ENTRY");
getch();
}
}while(!flag);
gotoxy(4,7);
cprintf("
Enter Patient Name->");
fflush(stdin);
gets(nameemp);
textcolor(4);
gotoxy(4,9);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄ");
rewind(fp);
rewind(fs);
while((fread(&e,sizeof(e),1,fp)==1) && (fread(&s,sizeof(s),1,fs)==1))
{
if(strcmp(id1,s.empno2)==0 && strcmp(dateemp,s.date)==0 &&
strcmp(id1,e.empno)==0)
{
textcolor(6);
highvideo();
gotoxy(24,10);
cprintf("Employee Name->%s",e.empname);
gotoxy(24,11);
cprintf("Employee No.->%s",e.empno);
gotoxy(24,13);
textcolor(10);
cprintf("Patient Name->%s",s.patient);
gotoxy(24,14);
cprintf("Patient Age->%d",s.age);
gotoxy(24,15);
cprintf("Patient Sex->%s",s.sex);
gotoxy(24,16);
cprintf("Medicine given->%s",s.medicine);
//printf("
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ");
break;
}
}
fclose(fp);
fclose(fs);
textcolor(10);
highvideo();
if(strcmp(id1,s.empno2)!=0 && strcmp(dateemp,s.date)!=0 )
{
textcolor(10);
gotoxy(6,10);
cprintf("
SORRY,RECORD NOT PRESENT");
}
gotoxy(22,21);
cprintf("
WANT TO SEARCH ANOTHER RECORD(y/n)->");
fflush(stdin);
another=getche();
}while((another=='y')||(another=='Y'));
textbackground(6);
textcolor(10+BLINK);
gotoxy(17,23);
cprintf("
Press M to Return to Main Menu and Esc to Exit....");
a=getch();
if(a==109)
{
main();
}
else
{
exit(0);
}
}//If statement for SEARCH RECORDS completed
}
/*************************************************************************
**/
/***************************DELETE
RECORDS***********************************/
DELETEEMP()
{
//If statement for DELETE RECORDS started
if(x>=192&&y==64&&x<=304&&y==64)
{
fs=fopen("medical3.dat","r+");
if(fs==NULL)
{
fs=fopen("medical3.dat","w+");
if(fs==NULL)
{
printf("cannot open file");
}
}
do
{
textbackground(8);
textcolor(7);
highvideo();
clrscr();
restrictmouseptr1();
hidemouseptr();
_setcursortype(_SOLIDCURSOR);
textcolor(10);
gotoxy(4,7);
cprintf("Ú");
gotoxy(77,7);
cprintf("¿");
for(a=8;a<20;a++)
{
gotoxy(4,a);
cprintf("³");
}
for(a=8;a<20;a++)
{
gotoxy(77,a);
cprintf("³");
}
gotoxy(4,20);
cprintf("À");
gotoxy(77,20);
cprintf("Ù");
textcolor(8+BLINK);
textbackground(7);
lowvideo();
gotoxy(4,6);
cprintf(" DELETE PATIENT ENTRY
");
textcolor(7);
textbackground(8);
highvideo();
for(a=3;a<79;a++)
{
for(b=5;b<6;b++)
{
gotoxy(a,b);
cprintf("Û");
}}
for(a=3;a<79;a++)
{
for(b=21;b<23;b++)
{
gotoxy(a,b);
cprintf("Û");
}}
for(b=6;b<22;b++)
{
gotoxy(3,b);
cprintf("Û");
}
for(b=6;b<22;b++)
{
gotoxy(78,b);
cprintf("Û");
}
textcolor(10);
highvideo();
gotoxy(5,7);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄ");
gotoxy(5,20);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄ");
textcolor(10);
highvideo();
gotoxy(6,9);
cprintf("Enter Employee No.->");
fflush(stdin);
gets(del1);
gotoxy(6,10);
cprintf("Enter Patient Name->");
fflush(stdin);
gets(petname);
gotoxy(6,11);
cprintf("Enter Date->");
fflush(stdin);
gets(dates);
fps=fopen("medical4.dat","w+");
rewind(fs);
while(fread(&s,sizeof(s),1,fs)==1)
{
if(strcmp(s.empno2,del1)!=0 && strcmp(s.date,dates)!=0 &&
strcmp(s.patient,petname)!=0)
fwrite(&s,sizeof(s),1,fps);
}
fclose(fs);
fclose(fps);
remove("medical3.dat");
rename("medical4.dat","medical3.dat");
fs=fopen("medical3.dat","r+");
gotoxy(24,12);
cprintf("RECORD DELETED SUCCESSFULY");
gotoxy(18,14);
cprintf("WANT TO DELETE ANOTHER RECORD(y/n)->");
fflush(stdin);
another2=getche();
}while((another2=='y')||(another2=='Y'));
gotoxy(16,19);
textbackground(6);
cprintf(" Press M to Return to Main Menu or Esc to Exit.... ");
a=getch();
if(a==109)
{
main();
}
else
{
exit(0);
}
}//If statement for DELETE RECORDS completed
}
/*************************************************************************
**/
/**************************UPDATE
RECORDS************************************/
UPDATEEMP()
{
//If statement for UPDATE RECORDS started
if(x>=192&&y==72&&x<=304&&y==72)
{
textcolor(1);
textbackground(6);
clrscr();
}//If statement for UPDATE RECORDS completed
}
/*************************************************************************
***/
/***********************For outsiders PATIENT
ENTRY*************************/
OUTENTRY()
{
if(x>=32&&y==104&&x<=152&&y==104)
{
ft=fopen("medical2.dat","r+");
if(ft==NULL)
{
ft=fopen("medical2.dat","w+");
if(ft==NULL)
{
printf("cannot open file");
}
}
do
{
textcolor(WHITE);
textbackground(8);
clrscr();
restrictmouseptr();
hidemouseptr();
_setcursortype(_SOLIDCURSOR);
textcolor(7);
textbackground(BLACK);
highvideo();
gotoxy(1,1);
cprintf("Ú");
for(a=2;a<79;a++)
{
gotoxy(a,1);
cprintf("Ä");
}
gotoxy(79,1);
cprintf("¿");
for(b=2;b<25;b++)
{
gotoxy(1,b);
cprintf("³");
}
gotoxy(1,25);
cprintf("À");
for(a=2;a<79;a++)
{
gotoxy(a,25);
cprintf("Ä");
}
gotoxy(79,25);
cprintf("Ù");
for(b=2;b<25;b++)
{
gotoxy(79,b);
cprintf("³");
}
gotoxy(2,2);
textcolor(BLACK+BLINK);
textbackground(WHITE);
lowvideo();
cprintf(" OUTSIDER PATIENT ENTRY
");
textcolor(10);
textbackground(8);
highvideo();
gotoxy(3,3);
cprintf("Ú");
gotoxy(4,2);
cprintf("
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄ");
gotoxy(77,3);
cprintf("¿");
for(a=4;a<20;a++)
{
gotoxy(3,a);
cprintf("³");
}
for(a=4;a<20;a++)
{
gotoxy(77,a);
cprintf("³");
}
gotoxy(3,20);
cprintf("À");
gotoxy(77,20);
cprintf("Ù");
gotoxy(4,20);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄ");
for(a=3;a<21;a++)
{
gotoxy(2,a);
textcolor(7);
cprintf("Û");
}
for(a=3;a<21;a++)
{
gotoxy(78,a);
textcolor(7);
cprintf("Û");
}
for(a=2;a<79;a++)
{
gotoxy(a,21);
textcolor(7);
cprintf("Û");
}
textcolor(10);
fseek(ft,0,SEEK_END);
gotoxy(6,4);
cprintf("Patient Number #");
gotoxy(6,6);
cprintf("Date->");
gotoxy(6,8);
cprintf("Patient Name->");
gotoxy(6,10);
cprintf("Age->");
gotoxy(6,12);
cprintf("Sex(M/F)->");
gotoxy(6,14);
cprintf("");
gotoxy(6,16);
cprintf("Medicine Desc.->");
do
{
gotoxy(22,22);
textbackground(8);
cprintf(" ");
gotoxy(22,4);
flag=1;
fflush(stdin);
gets(out.patientno);
if(strlen(out.patientno)==0)
{
flag=0;
sound(2500);
delay(300);
nosound();
gotoxy(22,22);
cprintf("PATIENT NO. CANNOT BE LEFT BLANK");
getch();}
}while(!flag);
do
{
gotoxy(22,22);
textbackground(8);
cprintf(" ");
gotoxy(12,6);
flag=1;
fflush(stdin);
gets(out.date);
if(strlen(out.date)==0)
{
flag=0;
sound(2500);
delay(300);
nosound();
gotoxy(22,22);
cprintf("DATE CAN NOT SET BLANK");
getch();
}
}while(!flag);
do
{
gotoxy(22,22);
textbackground(8);
cprintf(" ");
textcolor(7);
highvideo();
gotoxy(20,8);
cprintf(" ");
flag=1;
gotoxy(20,8);
fflush(stdin);
gets(out.patient);
if(strlen(out.patient)==0 || strlen(out.patient)>25)
{
flag=0;
sound(2500);
delay(300);
nosound();
gotoxy(22,22);
cprintf("PATIENT NAME CAN NOT SET BLANK OR >25");
getch();
}
}while(!flag);
gotoxy(11,10);
fflush(stdin);
scanf("%d",&out.age);
gotoxy(16,12);
fflush(stdin);
gets(out.sex1);
do
{
gotoxy(22,22);
textbackground(8);
cprintf(" ");
flag=1;
gotoxy(22,16);
fflush(stdin);
gets(out.medicine);
if(strlen(out.medicine)==0)
{
flag=0;
sound(2500);
delay(300);
nosound();
gotoxy(22,22);
textcolor(10);
highvideo();
cprintf("THIS FIELD CAN NOT BE SET BLANK");
getch();
}
}while(!flag);
fwrite(&out,sizeof(out),1,ft);
fclose(ft);
textcolor(10);
highvideo();
gotoxy(22,22);
cprintf("WANT TO ENTER ANOTHER RECORD->");
fflush(stdin);
another1=getche();
}while((another1=='y')||(another1=='Y'));
textbackground(6);
gotoxy(12,24);
cprintf(" Press M to Return to "MAIN MENU" or Esc to "EXIT".....
");
a=getch();
if(a==109)
{
main();
}
else
{
exit(0);
}
}//If statement for Outsiders Patient entry completed
}
/*************************************************************************
**/
/************************SEARCH RECORDS For
Outsiders***********************/
SEARCHOUT()
{
if(x>=32&&y==112&&x<=152&&y==112)
{
ft=fopen("medical2.dat","r+");
if(ft==NULL)
{
ft=fopen("medical2.dat","w+");
if(ft==NULL)
{
printf("cannot open file");
}
}
do
{
textcolor(WHITE);
textbackground(8);
clrscr();
restrictmouseptr();
hidemouseptr();
_setcursortype(_SOLIDCURSOR);
textcolor(BLACK+BLINK);
textbackground(7);
gotoxy(3,2);
cprintf(" SEARCH OUTSIDER PATIENT RECORD
");
textcolor(10);
textbackground(BLACK);
gotoxy(3,3);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄ");
gotoxy(3,3);
cprintf("Ú");
gotoxy(77,3);
cprintf("¿");
for(a=4;a<20;a++)
{
gotoxy(3,a);
cprintf("³");
}
for(a=4;a<20;a++)
{
gotoxy(77,a);
cprintf("³");
}
gotoxy(3,20);
cprintf("À");
gotoxy(77,20);
cprintf("Ù");
gotoxy(4,20);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄ");
for(a=3;a<21;a++)
{
gotoxy(2,a);
textcolor(7);
cprintf("Û");
}
for(a=3;a<21;a++)
{
gotoxy(78,a);
textcolor(7);
cprintf("Û");
}
for(a=3;a<78;a++)
{
gotoxy(a,21);
textcolor(7);
cprintf("Û");
}
textcolor(10);
textbackground(BLACK);
highvideo();
do
{
gotoxy(21,21);
textbackground(8);
cprintf(" ");
flag=1;
gotoxy(4,4);
cprintf("Enter Patient No.->");
fflush(stdin);
gets(id);
if(strlen(id)==0)
{
flag=0;
sound(2500);
delay(300);
nosound();
gotoxy(25,21);
cprintf("THIS FIELD CAN NOT BE LEFT BLANK");
getch();
}
}while(!flag);
do
{
gotoxy(21,21);
textbackground(8);
cprintf(" ");
flag=1;
gotoxy(4,5);
cprintf("
Enter Date->");
fflush(stdin);
gets(date1);
if(strlen(date1)==0)
{
flag=0;
sound(2500);
delay(300);
nosound();
gotoxy(25,21);
cprintf("ENTER DATE OF RECORD ENTRY");
getch();
}
}while(!flag);
gotoxy(4,7);
cprintf("
Enter Patient Name->");
fflush(stdin);
gets(name1);
textcolor(4);
gotoxy(4,9);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄ");
rewind(ft);
while(fread(&out,sizeof(out),1,ft)==1)
{
if(strcmp(id,out.patientno)==0)
{
textcolor(10);
textbackground(8);
highvideo();
gotoxy(6,8);
fflush(stdin);
cprintf("
Patient Name->%s",out.patient);
gotoxy(6,10);
cprintf("
Patient Age->%d",out.age);
gotoxy(6,12);
fflush(stdin);
cprintf("
Patient Sex->%s",out.sex1);
gotoxy(6,14);
fflush(stdin);
cprintf("
Medicine given->%s",out.medicine);
}
}
textcolor(10);
highvideo();
if(strcmp(id,out.patientno)!=0)
{
textcolor(10);
gotoxy(6,10);
cprintf("
SORRY,RECORD NOT PRESENT");
}
fclose(ft);
gotoxy(22,21);
cprintf("
WANT TO SEARCH ANOTHER RECORD(y/n)->");
fflush(stdin);
another=getche();
}while((another=='y')||(another=='Y'));
textbackground(6);
textcolor(10+BLINK);
gotoxy(17,23);
cprintf("
Press M to Return to Main Menu and Esc to Exit....");
a=getch();
if(a==109)
{
main();
}
else
{
exit(0);
}
}
}
/*************************************************************************
**/
/*****************************UPDATE RECORD FOR
Outsiders********************/
UPDATEOUT()
{
if(x>=192&&y==96&&x<=304&&y==96)
{
ft=fopen("medical2.dat","r+");
if(ft==NULL)
{
ft=fopen("medical2.dat","w+");
if(ft==NULL)
{
printf("cannot open file");
}
}
do
{
textcolor(7);
textbackground(8);
clrscr();
restrictmouseptr();
hidemouseptr();
_setcursortype(_SOLIDCURSOR);
textcolor(7);
highvideo();
printf("Enter Patient No to Modify->");
fflush(stdin);
gets(updateno);
printf("
Enter Patient Name->");
fflush(stdin);
gets(update);
clrscr();
rewind(ft);
while(fread(&out,sizeof(out),1,ft)==1)
{
if(strcmp(updateno,out.patientno)==0)
{
gotoxy(2,2);
textcolor(BLACK+BLINK);
textbackground(WHITE);
lowvideo();
cprintf(" UPDATE PATIENT ENTRY
");
textcolor(10);
textbackground(8);
highvideo();
gotoxy(3,3);
cprintf("Ú");
gotoxy(4,2);
cprintf("
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄ");
gotoxy(77,3);
cprintf("¿");
for(a=4;a<20;a++)
{
gotoxy(3,a);
cprintf("³");
}
for(a=4;a<20;a++)
{
gotoxy(77,a);
cprintf("³");
}
gotoxy(3,20);
cprintf("À");
gotoxy(77,20);
cprintf("Ù");
gotoxy(4,20);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄ");
for(a=3;a<21;a++)
{
gotoxy(2,a);
textcolor(7);
cprintf("Û");
}
for(a=3;a<21;a++)
{
gotoxy(78,a);
textcolor(7);
cprintf("Û");
}
for(a=2;a<79;a++)
{
gotoxy(a,21);
textcolor(7);
cprintf("Û");
}
//textcolor(10);
//textbackground(8);
gotoxy(6,4);
cprintf("Patient Number #");
gotoxy(6,6);
cprintf("Date->");
gotoxy(6,8);
cprintf("Patient Name->");
gotoxy(6,10);
cprintf("Age->");
gotoxy(6,12);
cprintf("Sex(M/F)->");
gotoxy(6,14);
cprintf("");
gotoxy(6,16);
cprintf("Medicine Desc.->");
do
{
gotoxy(22,22);
textbackground(8);
cprintf(" ");
gotoxy(22,4);
flag=1;
fflush(stdin);
gets(out.patientno);
if(strlen(out.patientno)==0)
{
flag=0;
sound(2500);
delay(300);
nosound();
gotoxy(22,22);
cprintf("PATIENT NO. CANNOT BE LEFT BLANK");
getch();}
}while(!flag);
do
{
gotoxy(22,22);
textbackground(8);
cprintf(" ");
gotoxy(12,6);
flag=1;
fflush(stdin);
gets(out.date);
if(strlen(out.date)==0)
{
flag=0;
sound(2500);
delay(300);
nosound();
gotoxy(22,22);
cprintf("DATE CAN NOT SET BLANK");
getch();
}
}while(!flag);
do
{
gotoxy(22,22);
textbackground(8);
cprintf(" ");
textcolor(7);
highvideo();
gotoxy(20,8);
cprintf(" ");
flag=1;
gotoxy(20,8);
fflush(stdin);
gets(out.patient);
if(strlen(out.patient)==0 || strlen(out.patient)>25)
{
flag=0;
sound(2500);
delay(300);
nosound();
gotoxy(22,22);
cprintf("PATIENT NAME CAN NOT SET BLANK OR >25");
getch();
}
}while(!flag);
gotoxy(11,10);
fflush(stdin);
scanf("%d",&out.age);
gotoxy(16,12);
fflush(stdin);
gets(out.sex1);
do
{
gotoxy(22,22);
textbackground(8);
cprintf(" ");
flag=1;
gotoxy(22,16);
fflush(stdin);
gets(out.medicine);
if(strlen(out.medicine)==0)
{
flag=0;
sound(2500);
delay(300);
nosound();
gotoxy(22,22);
textcolor(10);
highvideo();
cprintf("THIS FIELD CAN NOT BE SET BLANK");
getch();
}
}while(!flag);
fseek(ft,sizeof(out),SEEK_CUR);
fwrite(&out,sizeof(out),1,ft);
break;
}
}
fclose(ft);
textcolor(10);
highvideo();
gotoxy(22,22);
cprintf("WANT TO MODIFY ANOTHER RECORD->");
fflush(stdin);
another1=getche();
}while((another1=='y')||(another1=='Y'));
textbackground(6);
gotoxy(12,24);
cprintf(" Press M to Return to "MAIN MENU" or Esc to "EXIT".....
");
a=getch();
if(a==109)
{
main();
}
else
{
exit(0);
}
}//If statement for Outsiders Patient entry completed
}
/*************************************************************************
**/
/***************************Delete records Form For
outsiders***************/
DELETEOUT()
{
if(x>=192&&y==88&&x<=304&&y==88)
{
ft=fopen("medical2.dat","r+");
if(ft==NULL)
{
ft=fopen("medical2.dat","w+");
if(ft==NULL)
{
printf("cannot open file");
}
}
do
{
textbackground(8);
textcolor(7);
highvideo();
clrscr();
restrictmouseptr1();
hidemouseptr();
_setcursortype(_SOLIDCURSOR);
textcolor(10);
gotoxy(4,7);
cprintf("Ú");
gotoxy(77,7);
cprintf("¿");
for(a=8;a<20;a++)
{
gotoxy(4,a);
cprintf("³");
}
for(a=8;a<20;a++)
{
gotoxy(77,a);
cprintf("³");
}
gotoxy(4,20);
cprintf("À");
gotoxy(77,20);
cprintf("Ù");
textcolor(8+BLINK);
textbackground(7);
lowvideo();
gotoxy(4,6);
cprintf(" DELETE OUTSIDER PATIENT RECORD
");
textcolor(7);
textbackground(8);
highvideo();
for(a=3;a<79;a++)
{
for(b=5;b<6;b++)
{
gotoxy(a,b);
cprintf("Û");
}}
for(a=3;a<79;a++)
{
for(b=21;b<23;b++)
{
gotoxy(a,b);
cprintf("Û");
}}
for(b=6;b<22;b++)
{
gotoxy(3,b);
cprintf("Û");
}
for(b=6;b<22;b++)
{
gotoxy(78,b);
cprintf("Û");
}
textcolor(10);
highvideo();
gotoxy(5,7);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄ");
gotoxy(5,20);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄ");
textcolor(10);
highvideo();
gotoxy(6,9);
cprintf("Enter Patient No. to Delete->");
fflush(stdin);
gets(del);
fpt=fopen("medical6.dat","w+");
rewind(ft);
while(fread(&out,sizeof(out),1,ft)==1)
{
if(strcmp(out.patientno,del)!=0)
fwrite(&out,sizeof(out),1,fpt);
}
fclose(ft);
fclose(fpt);
remove("medical2.dat");
rename("medical6.dat","medical2.dat");
ft=fopen("medical2.dat","r+");
fclose(ft);
//fclose(fpt);
gotoxy(24,12);
cprintf("RECORD DELETED SUCCESSFULY");
gotoxy(18,14);
cprintf("WANT TO DELETE ANOTHER RECORD(y/n)->");
fflush(stdin);
another2=getche();
}while((another2=='y')||(another2=='Y'));
gotoxy(16,19);
textbackground(6);
cprintf(" Press M to Return to Main Menu or Esc to Exit.... ");
a=getch();
if(a==109)
{
main();
}
else
{
exit(0);
}
}
}
/*************************************************************************
**/
/****************************HELP
TOPICS*************************************/
HELPTOPICS()
{
//IF statement for HELP TOPICS started
if(x>=344&&y==56&&x<=456&&y==56)
{
textbackground(1);
textcolor(10);
clrscr();
restrictmouseptr();
hidemouseptr();
lowvideo();
_setcursortype(_NOCURSOR);
textcolor(YELLOW+BLINK);
textbackground(4);
gotoxy(1,1);
cprintf(" WELCOME TO MEDICAL RECORD KEEPING SYSTEM "
HELP
" ");
textcolor(10);
textbackground(1);
highvideo();
gotoxy(2,3);
cprintf("This system is built using mouse programming and drop down
menus.");
gotoxy(2,4);
cprintf("In this system you can Enter 'n' No. of Records.");
gotoxy(2,6);
cprintf("1First option "FILE" can be selected by clicking on
it.Click
event will show a drop down menu,in which you can select any one of the
options.First option is " ADD EMP .RECORD " which is used to
add
details about employee.The second option is" NEW ENTRY "which is
used to enter the new record about patient.The third option is
"SEARCH RECORD" which is used to search the record of any
patient.");
gotoxy(2,13);
cprintf("2Second menu is "EDIT",can be selected by clicking on
it.the
First option in drop down menu is"DELETE RECORD"which is used to
delete a particular record of any patient.The second option
is"SEARCH
RECORD" which is used to search the record of a particular
patient.
");
gotoxy(2,18);
cprintf("3Third menu is "HELP",which provide you information about
using the system.");
gotoxy(2,20);
cprintf("4Fourth menu is "EXIT", used to quit from the system");
textcolor(YELLOW);
textbackground(RED);
highvideo();
gotoxy(2,25);
cprintf(" Press Esc key to quit or M to return to Main
Menu... ");
a=getch();
if(a==109)
{
for(a=25;a>0;a--)
{
delay(10);
textbackground(8);
gotoxy(1,a);
cprintf("
");
}
main();
}
else
{
for(a=25;a>0;a--)
{
delay(10);
textbackground(8);
gotoxy(1,a);
cprintf("
");
}
exit(0);
}
}
}
/*************************************************************************
**/
/********************************About....********************************
***/
ABOUT()
{
if(x>=344&&y==64&&x<=456&&y==64)
{
//For HELP menu
gotoxy(47,5);
textcolor(BLACK);
textbackground(RED);
cprintf(" HELP ");
gotoxy(42,6);
highvideo();
textcolor(WHITE);
textbackground(1);
cprintf("ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ");
for(b=7;b<13;b++)
{
gotoxy(41,b);
textbackground(1);
cprintf(" ");
}//HELP menu ended
textcolor(10);
textbackground(RED);
highvideo();
for(a=25;a<=47;a++)
{
gotoxy(a,17);
cprintf("Ä");
}
gotoxy(39,48);
cprintf("¿");
gotoxy(24,17);
cprintf("Ú");
for(b=18;b<23;b++)
{
gotoxy(24,b);
cprintf("³");
}
gotoxy(24,23);
cprintf("À");
for(a=25;a<48;a++)
{
gotoxy(a,b=23);
cprintf("Ä");
}
gotoxy(48,23);
cprintf("Ù");
for(b=18;b<23;b++)
{
gotoxy(a=48,b);
cprintf("³");
}
gotoxy(25,18);
cprintf(" CREATED BY-: ");
gotoxy(25,19);
cprintf(" ");
gotoxy(25,20);
cprintf(" IGCT COMPUTERS,Nagpur-22 ");
gotoxy(25,21);
cprintf(" FOR BCA,MCM,PGDCCA ");
gotoxy(25,22);
cprintf(" Ph : +919373144662 ");
}
}
Related Links :
Setting File Attributes By using C
#include
#include
#define SE 112
#define US 7
int get_file_attrib(char fname[40]);
void setfattr(void);
void setattr(int,int,int);
char fname[40];
char far *scr;
char far *mode1;
FILE *fp;
int mode=0;
int r,c,i,j,b,attrib,flen=1;
int v=0;
char ch,t;
void main()
{
_AH=0;
_AL=3;
geninterrupt(0x10);
if((*mode1 &0x30)== 0x30)
scr=(char far*) 0xb0000000;
else
scr=(char far*) 0xb8000000;
begin:
r=4;
c=20;
clrscr();
gotoxy(21,5);
printf("1. Select a File.");
gotoxy(21,6);
printf("2. View Attributes.");
gotoxy(21,7);
printf("3. Set Attributes.");
gotoxy(21,8);
printf("4. Remove Attributes.");
gotoxy(21,9);
printf("5. Exit.");
gotoxy(21,11);
printf("Enter Choice: [1]");
while(ch!=13)
{
for(i=4;i<11;i++)
setattr(i,20,US);
setattr(r,c,SE);
gotoxy(36,11);
ch=getch();
if(ch=='H'||ch=='h')
{
if(r==4)
r=4;
else
r--;
}
else if(ch=='P'||ch=='p')
{
if(r==8)
r=8;
else
r++;
}
else if(ch=='1')
{
r=4;
}
else if(ch=='2')
{
r=5;
}
else if(ch=='3')
{
r=6;
}
else if(ch=='4')
{
r=7;
}
else if(ch=='5')
{
r=8;
}
t=r+48-3;
printf("%c",t);
gotoxy(36,13);
}
ch=' ';
b=r-3;
clrscr();
switch(b)
{
case 1:
strcpy(fname,NULL);
flen=0;
printf("Please Enter Valid Filename with Extension: ");
scanf("%s",fname);
attrib = get_file_attrib(fname);
if(attrib & FA_LABEL)
{
flen=2;
}
if(attrib & FA_DIREC)
{
flen=2;
}
if(flen!=2)
{
fp=fopen(fname,"rb");
if(fp==NULL)
{
printf("NON_EXISTING FILE");
flen=1;
getch();
}
fclose(fp);
}
v=strlen(fname);
for(i=0;i
fname[i]=tolower(fname[i]);
}
break;
case 2:
if(flen==1)
{
printf("No Valid Filename Entered.");
getch();
goto endl;
}
v=0;
printf("%s is",fname);
attrib = get_file_attrib(fname);
if(attrib & FA_RDONLY)
{
printf("Read-only file");
v=1;
}
if(attrib & FA_HIDDEN)
{
printf("Hidden file");
v=1;
}
if(attrib & FA_SYSTEM)
{
printf("System file");
v=1;
}
if(attrib & FA_LABEL)
{
printf("Volume label");
v=1;
}
if(attrib & FA_DIREC)
{
printf("Directory");
v=1;
}
if(attrib & FA_ARCH)
{
printf("Archive file");
v=1;
}
printf(".");
if(v==1)
getch();
endl:
v=0;
break;
case 3:
if(flen==1)
{
printf("No Valid Filename Entered.");
getch();
goto endl1;
}
mode=1;
setfattr();
endl1:
break;
case 4:
if(flen==1)
{
printf("No Valid Filename Entered.");
getch();
goto endl2;
}
mode=2;
setfattr();
endl2:
break;
case 5:
goto end;
}
goto begin;
end:
clrscr();
}
void setattr(int row,int col,int attr)
{
int i;
for(i=0;i<23;i++)
{
*(scr+row*160+col*2+1)=attr;
col++;
}
}
int get_file_attrib(char fname[40])
{
return(_chmod(fname,0));
}
void setfattr()
{
begin1:
r=4;
c=20;
clrscr();
gotoxy(21,5);
printf("1. Read Only.");
gotoxy(21,6);
printf("2. Hidden.");
gotoxy(21,7);
printf("3. System.");
gotoxy(21,8);
printf("4. Archive.");
gotoxy(21,9);
printf("5. Back.");
gotoxy(21,11);
printf("Enter Choice: [1]");
while(ch!=13)
{
for(i=4;i<11;i++)
setattr(i,20,US);
setattr(r,c,SE);
gotoxy(36,11);
ch=getch();
if(ch=='H'||ch=='h')
{
if(r==4)
r=4;
else
r--;
}
else if(ch=='P'||ch=='p')
{
if(r==8)
r=8;
else
r++;
}
else if(ch=='1')
{
r=4;
}
else if(ch=='2')
{
r=5;
}
else if(ch=='3')
{
r=6;
}
else if(ch=='4')
{
r=7;
}
else if(ch=='5')
{
r=8;
}
t=r+48-3;
printf("%c",t);
gotoxy(36,13);
}
ch=' ';
b=r-3;
clrscr();
attrib=get_file_attrib(fname);
if(mode==1)
{
switch(b)
{
case 1:
_chmod(fname,1,attrib|FA_RDONLY);
break;
case 2:
_chmod(fname,1,attrib|FA_HIDDEN);
break;
case 3:
_chmod(fname,1,attrib|FA_SYSTEM);
break;
case 4:
_chmod(fname,1,attrib|FA_ARCH);
break;
case 5:
goto end1;
}
}
if(mode==2)
{
switch(b)
{
case 1:
v=~FA_RDONLY;
attrib=attrib&v;
_chmod(fname,1,attrib);
break;
case 2:
v=~FA_HIDDEN;
attrib=attrib&v;
_chmod(fname,1,attrib);
break;
case 3:
v=~FA_SYSTEM;
attrib=attrib&v;
_chmod(fname,1,attrib);
break;
case 4:
v=~FA_ARCH;
attrib=attrib&v;
_chmod(fname,1,attrib);
break;
case 5:
goto end1;
}
}
v=0;
goto begin1;
end1:
clrscr();
mode=0;
}
Related Links :
If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE
More Useful Topics... |
|
History Of C..
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.
My 1st Program...
#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}
Next Step...
#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");
printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");
}