I need some help with delay functions,
First off, I know about windows.h, and the sleep(x) function.
But I can't use windows.h because it conflicts with my allegro.h causing my compiler to spew out errors from allegro.h everywhere.
Is there another function that i could use (Other than having to write out over 9000! loops to get the delay)?

Recommended Answers

All 2 Replies

Here is another one, but it delays process.

#include <iostream>
#include <ctime>

using namespace std;

void delay(int milliSec){
	
	const unsigned int clk_strt = clock();
	
	while(clock() - clk_strt < milliSec)
		continue;
}
int main(){
	
	for(int i = 0; i < 5; i++)
	{
		delay(1000);
		cout<< (i+1) << " seconds has passed\n";
	}
}
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.