1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h> #include <unistd.h> int main(void) { /* Variable declaration and initialization */ int TimeOut; TimeOut = 10; while (TimeOut) { /* Decrease the countdown */ --TimeOut; /* Wait for one second */ sleep(1); /* And print the message */ printf("The countdown in %i\r", TimeOut); /* Flush the output buffer (this is needed for \r) */ fflush(stdout); if (TimeOut == 0) { printf("Timeout reached!\n"); /* Kill the loop */ break; } } return 0; }
if (TimeOut == 0)) the zero is also shown at the end of the string even though I did not define that number in the
printf(). Like this:
Timeout reached! 0
Is there a way to solve this problem? How?
edited 1×, last 26.12.18 01:19:12 pm