hello i am trying to get the output one time in while loop
While(1){
if( current->tm_hour == 10 && current->tm_min == 0 ){
Start_Function();
std::cout << "Started" << std::endl;
}
if( current->tm_hour == 12 && current->tm_min == 0 ){
End_Function();
std::cout << "Ended" << std::endl;
}
Sleep(5000);
}
and i use sleep to refresh every 5 sec
so i want when the current Hour & minut = 10 & 00
it give me output Started and it call the function just one time and it contiune refreshing
Edit: In light of @Joachim Pileborg’s comment
Alternate solution
The code above will force it to only do each of the operation’s once and continue refreshing…
My original comment:
In the command line/terminal as you’ve foundout the output is printed out continuously. Depending on what operating system you use (window/linux/mac) the solution will be easy or not so easy.
I recommend looking up the
gotoxy()functionhttp://www.programmingsimplified.com/c/conio.h/gotoxy
provided by the “conio.h” library for Windows or “ncurses.h” for Linux.
“ncurses.h” doesn’t have the
gotoxy()but it will provide you with a way to do the same.