Problems with code(password masking)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<string.h>
#include<process.h>
#include<alloc.h>
void main()
{
 clrscr();
 int gd=DETECT,gm;
 initgraph(&gd,&gm,"C:\\TC\\BGI");
 setbkcolor(BLUE);
 setcolor(RED);
 settextstyle(1,0,5);
 outtextxy(100,100,"WELCOME TO C++ WORLD");
 delay(2000);
 setcolor(RED);
 settextstyle(1,0,2);
 outtextxy(200,200,"Please enter the password");
   int c,l,j=0;
   char pass[4];
   char r[4] = "pass";
   for (l=0;l<4;l++)
   {
      pass[l] = getch();
      setbkcolor(l+1);
      setcolor(WHITE);
      outtextxy(220+10*l,220,"*");
   }
   for (j=0;j<4;j++)
   {
      if (pass[j]==r[j])
	 c++;
   }
/* char pass[9],pass1[9]="Code";//the password is Code
 int i=0;
 cin.getline(pass,9);
 memset(pass,0,9);
 pass[0]=getch();
 while(pass[i]!=13)
 {
	i++;
	cout<<"*";
	pass[i]=getch();
 }
 */
 if(c==4)
 {
	setcolor(GREEN);
	outtextxy(250,250,"ACCESS GRANTED");
	delay(2000);
 }
 else
 {
	setcolor(YELLOW);
	outtextxy(250,250,"ACCESS ABORTED");
	delay(2000);
	clrscr();
	exit(0);
 }
 void   *buffer;
 unsigned int size;
 line(230,330,370,330);
 line(230,350,370,350);
 line(226,335,226,345);
 line(226,335,230,330);
 line(226,345,230,350);
 line(374,335,374,345);
 line(374,335,370,330);
 line(374,345,370,350);
 outtextxy(265,365,"Loading");  //put you text here
 int x=232,y=336,x1=236,y1=344;
 for(int i=1;i<5;i++)
 {
	setfillstyle(1,RED);
	bar(x,y,x1,y1);
	x=x1+2;
	x1=x1+6;
 }
 size=imagesize(232,336,256,344);
 buffer=malloc(size);
 getimage(232,336,256,344,buffer);
 x=232;
 int m=0;
 while(!kbhit())
 {
	putimage(x,336,buffer,XOR_PUT);
	x=x+2;
	if(x>=350)
	{
		m++;
		x=232;
		if(m==5)                         // m is no of times bar moves
		return;
	}
	putimage(x,336,buffer,XOR_PUT);
	delay(20);                      // delay(time) is the speed of moving
				// less delay means fast and vice versa
 }


 getch();
 closegraph();
}

I have a problem in this code while entering the password and even the gotoxy function seems not be working for moving the entered text after this line"Please enter the password",I am using Turbo C++ 3.0 (forced to use this because it is my school project) and also i am a beginner.I have copied some part of the code from the net too like the loading part and password masking.
Last edited on
Topic archived. No new replies allowed.