让程序暂停

#include 
#include
#include

void sleep(int nbr_seconds); //记得加分号 

int main(void)
{
	int ctr;
	int wait = 16;
	
	printf("Delay for %d seconds\n",wait);
	printf(">");
	for(ctr=1;ctr<=wait;ctr++){
		printf(".");
		fflush(stdout); //force dot to print on buffered machines
		sleep((int) 1);
	} 
	printf("\nDone!\n");
	return 0;
}

void sleep(int nbr_seconds){
	clock_t goal;
	goal = (nbr_seconds*CLOCKS_PER_SEC)+clock();
	while(goal>clock()){
		;
	}
}

《21天学通C语言(第6版·修订版)》

你可能感兴趣的:(C/C++,C语言学习)