I want when I hit my first button (0x01) go inside the while-loop and start the timer. But I want to print in my console "Hi" everytime I hit the second button 0x02 inside the while-loop. But the program is not printing "Hi". It's just counting the timer.
int main(void)
{
int button=0, button_2=0;
while(1)
{
button = 0x01
button_2 = 0x02
if(button==0)
{
while(1)
{
if(button_2==0)
{
printf("Hi");
}
if (seconds<=59)
{
printf("Seconds = %d\n", seconds);
}
else
{
minutes++;
seconds=0;
printf("Minutes = %d\n", minutes);
}
}
}
} return 0;
}
The printf
function is line buffered by default. Either print entire lines of call fflush(stdout);
after the printf
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.