The sleep function here is functioning differently on Windows and Linux.
#include <stdio.h>#include <stdlib.h>#include <stdbool.h>#include <string.h>#include <unistd.h>int main(){printf("Press 1 to apply for Password Change Request...\n"); printf("\nPress any other key to try again"); fflush(stdout); for(int j=0; j<2; j++) { sleep(1); printf(".."); }}return 0;
On Windows, it is working as it is meant to, waiting for a second then printing ..
and then again waiting for a second and then printing ..
.But on Linux, it is waiting for whole 2 seconds and then printing ....
altogether.
What should I do to fix it?
I am using MinGW on Windows.