hi
can anyone help me, how can i exit an infinite loop??
i made a clock and i want that by pressing any key or ESC the prog shud exit

here is the code
==============================================

#include<iostream.h>
#include<stdlib.h>
#include<conio.h>
void display()
{
long int i,j;

for(i=0;i<15000;i++)
	{
	for(j=0;j<15000;j++);
	}

}
void main()
{
clrscr();
int a;
int b=0;
int c=1;
for(a=0;a<60;a++)
{
clrscr();
cout<<c;
cout<<":";
cout<<b;
cout<<":";
cout<<a;
if(a==59)
{
b++;
a=-1;
if(b==60)
{
c++;
b=0;
}
if(c==13)
{
c=1;
}
}

display();

/*if(getche()==27)
	exit(0);    */


}
getch();

}

First, format your code.
Second, look up the kbhit() and getch() functions in your compiler documentation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.