here is the code link: https://hastebin.com/exolinigas.cpp
is there any way to print the printf which is after infinite loop?
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
19 messages · Page 1 of 1 (latest)
here is the code link: https://hastebin.com/exolinigas.cpp
is there any way to print the printf which is after infinite loop?
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
no no the link has cpp at last. Please visit the link its c source code.
#include <stdio.h>
#include <time.h>
#include <windows.h>
void gotoxy(int x, int y)
{
COORD c; ///COORD is a structure to hold screen COORDinates X and Y.
c.X=x;
c.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c); //1. HANDLE 2. COORD
}
void c_time()
{
while(1){
time_t s = time(NULL);
struct tm* cur_time;
cur_time= localtime(&s);
gotoxy(5, 5);
printf("Time: %02d:%02d:%02d", cur_time->tm_hour, cur_time->tm_min, cur_time->tm_sec);
}
}
int main(){
c_time();
printf("Here");
return 0;
}
```cpp
int main() {
return 0;
}
```
That busy loop you have there will eat 100% of a CPU core's cycles (or at least try very hard)
It'll print the time thousands of times per second
yeah! Is there any better way to do that using c?
Use clock_nanosleep()
as for the printf, you could try
int main(void) {
gotoxy(5, 6);
printf("Here");
c_time();
return 0;
}```
(assuming those coordinates are absolute)
yeah, but the problem is I need to do more stuff after c_time() function called.