Need help. Can someone explain this to me?

I need help. I understand most of tgis codes but I struggles ononunderstanding understanding that do statement

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
  # include<conio.h>
 #include<iostream.h>
# include<stdio.h>
# include<graphics.h>
 #include<string.h>
void main()
{
int f=0,i=0,ch;
clrscr();
char u[10],p[20],ch1,c,user[]="daniels",pas[]="ashganda";
textcolor(14);
	gotoxy(22,8);
	cprintf(" LOGIN ");
	gotoxy(23,11);
	cprintf("USER NAME : ");
	gotoxy(23,15);
	cprintf("PASSWORD : ");
	gotoxy(36,11);
	cin>>u;
	gotoxy(36,15);
	do
	{
		p[i]=getch();
		if(p[i]==13 || i==8)
		{
			break;
		}
		else if(p[i]==8 && i>0)
		{
			cprintf("%c%c%c",8,32,8);
			i--;
		}
		else
		{
			cout<<"*";
			i++;
		}
	}while(p[i]!=13 || i==8);
	p[i]='\0';
	gotoxy(32,18);
	textcolor(RED+BLINK);
	cprintf("O");
	gotoxy(33,18);
	cout<<"k";
	gotoxy(47,18);
	textcolor(RED+BLINK);
	cprintf("E");
	gotoxy(48,18);
	cout<<"xit";
	textcolor(15);
	ch=getch();
	if(ch=='o' || ch=='O')
	{
	if(strcmp(user,u)==0 && strcmp(pas,p)==0)
		{
			f=1;

}
if(f==1)
{ 	cout<<"screen";

}

else
{
	clrscr();
	gotoxy(25,15);
	cout<<"Wrong user or password";
	getch();
	main();
}
}
}
Hello Chrome68,

line 21 is the start of a do/while loop. line 38 is the end of the loop. The while condition determines if the loop will continue or end.

See http://www.cplusplus.com/doc/tutorial/control/ the do/while loop is about 1/3 down the page.

Hope that helps,

Andy
Topic archived. No new replies allowed.