how can i insert the code for entering a password here?? the password should be in the main window...and it should be replaced by asterisk...HOW??? tnx
#include<stdio.h>
#include<conio.h>
#include<dos.h>
struct phone
{
char name[20];
char ad[40];
char ph[20];
};
struct phone ar[100];
int n=0;
void wfile();
void rfile();
void SearchByName();
void SearchByPhone();
void update();
void entry();
void view();
void del();
void menu();
void main(void)
{
char choice;
rfile();
window(1,1,80,25);
textbackground(0);
clrscr();
while(1)
{
clrscr();
menu();
gotoxy(23,15);
choice=getche();
switch(choice)
{
case'1': entry(); break;
case'2': view(); break;
case'3': SearchByName(); break;
case'4': SearchByPhone(); break;
case'5': update(); break;
case'6': del(); break;
case'7': gotoxy(34,7);
wfile();
clrscr();
gotoxy(34,9);
printf("<<<<Thank You>>>>");
getch(); exit(1);
}
}
}
void menu(void)
{
int i;
printf("\n\n");
printf("\t\t\t %c WELCOME TO THE INVENTORY SYSTEM OF IT ROOMS %c\n\n",127,127);
printf("\t\t\t [1] New Entry\n");
printf("\t\t\t [2] View Record\n");
printf("\t\t\t [3] Search By Name\n");
printf("\t\t\t [4] Search By Phone\n");
printf("\t\t\t [5] Update\n");
printf("\t\t\t [6] Delete\n");
printf("\t\t\t [7] Exit\n\n");
printf("\t\t\t Enter your choice: ");
}
void wfile(void)
{
FILE*fptr;
if(n<1)
{
printf("Can't write empty list.\n");
return;
}
if((fptr=fopen("aphone.rec","wb"))==NULL)
{
printf("Can't open file aphone.rec\n");
}
else
{
fwrite(&ar,sizeof(ar[0]),n,fptr);
fclose(fptr);
printf("File of %d record saved.\n",n);
}
}
void rfile(void)
{
FILE*fptr;
if((fptr=fopen("aphone.rec","rb"))==NULL)
{
printf("Can't open file aphone.rec\n");
}
else
{
while(fread(&ar[n],sizeof(ar[n]),1,fptr)==1)
n++;
fclose(fptr);
printf("\nFile read.Total record is now %d.\n",n);
}
}
void SearchByName(void)
{
char*s;
int j, record=0;
int found=0;
do{
clrscr();
found=0;
record=0;
gotoxy(34,5);
printf("Search By Name...");
gotoxy(34,7);
printf("Enter Name:");
scanf("%s",s);
if(n<1)
{
gotoxy(34,5);
printf("Empty list");
}
for(j=0;j<n;j++)
{
if(strcmp(s,ar[j].name)==0)
{
if(record>0)
{
clrscr();
gotoxy(34,5);
printf("Search By Name...");
gotoxy(34,7);
printf("Enter name: %s",s);
}
gotoxy(34,9);
printf("Record No: %d\n",j+1);
gotoxy(34,10);
printf("Name: %s\n",ar[j].name);
gotoxy(34,11);
printf("Address: %s\n",ar[j].ad);
gotoxy(34,12);
printf("Phone No: %s\n",ar[j].ph);
found=1;
record++;
gotoxy(34,14);
printf(">>next>>");
getche();
}
}
if(found==0)
{
gotoxy(34,9);
printf("Record not found");
}
else
{
gotoxy(34,14);
printf("%d record found",record);
}
gotoxy(34,15);
printf("Do you want to Search again (y/n): ");
}while(getche()=='y'||getche()=='Y');
}
void SearchByPhone(void)
{
char*p;
int j;
int found=0;
do{
clrscr();
found=0;
gotoxy(34,5);
printf("Search by phone number...");
gotoxy(34,7);
printf("Enter Phone Number:");
scanf("%s",p);
if(n<1)
{
gotoxy(34,5);
printf("Empty list");
}
for(j=0;j<n;j++)
{
if(strcmp(p,ar[j].ph)==0)
{
gotoxy(34,9);
printf("Record No: %d\n",j+1);
gotoxy(34,10);
printf("\tName: %s\n",ar[j].name);
gotoxy(34,11);
printf("\tAddress: %s\n",ar[j].ad);
gotoxy(34,12);
printf("\tPhone No: %s\n",ar[j].ph);
found=1;
}
}
if(found==0)
{
gotoxy(34,10);
printf("Record not found");
}
gotoxy(34,14);
printf("Do you want to Search again(y/n):");
}while(getche()=='y'||getche()=='Y') ;
}
void update(void)
{
int recno;
char*a;
char*p;
char*ap;
clrscr();
do{
// clrscr();
gotoxy(34,5);
printf("Update");
gotoxy(34,7);
printf("Enter record number to update:");
scanf("%d",&recno);
if(recno<1||recno>n)
{
gotoxy(34,10);
sound(400);
printf("invalid Record Number");
delay(500);
nosound();
getche();
return;
}
recno--;
gotoxy(34,9);
printf("Name:%s",ar[recno].name);
gotoxy(34,10);
printf("Enter new address:");
scanf("%s",a);
strcpy(ar[recno].ad,a);
gotoxy(34,11);
printf("Enter new phone number:");
scanf("%s",p);
strcpy(ar[recno].ph,p);
gotoxy(34,14);
printf("Do you want to Update another(y/n):");
}while(getche()=='y'||getche()=='Y');
}
void entry(void)
{
do{
clrscr();
gotoxy(34,5);
printf("Record No: %d",n+1);
gotoxy(34,7);
printf("Enter name:");
gets(ar[n].name);
gotoxy(34,8);
printf("Enter address:");
gets(ar[n].ad);
gotoxy(34,9);
printf("Enter phone number:");
gets(ar[n].ph);
n=n+1 ;
gotoxy(34,12);
printf("Do you want to add another (y/n);");
}while(getche()=='y'||getche()=='Y');
}
void view(void)
{
int i;
clrscr();
for(i=0;i<n;i++)
{
gotoxy(34,5);
printf("Record No: %d\n",i+1);
gotoxy(34,6);
printf("Name: %s\n",ar[i].name);
gotoxy(34,7);
printf("Address: %s\n",ar[i].ad);
gotoxy(34,8);
printf("\tPhone No: %s\n",ar[i].ph);
gotoxy(34,12);
printf(">>next>>");
getche();
clrscr();
}
gotoxy(34,13);
printf("<____End of record____>");
getch();
}
void del(void)
{
int recno,j;
clrscr();
do{
gotoxy(34,5);
printf("Enter record number to delete:");
scanf("%d",&recno);
if(recno<1||recno>n)
{
gotoxy(34,6);;
sound(400);
printf("Invalid Record Number");
delay(500);
nosound();
getche();
return;
}
recno--;
for(j=recno;j<n;j++)
{
ar[j]=ar[j+1];
}
n--;
gotoxy(34,7);
printf("Sucessfully Deleted...");
gotoxy(34,9);
printf("Do you want to delete any more(y/n):");
}while(getche()=='y'||getche()=='Y');
{
getch();
}}