C while loop only works if statement is true?

I was looking at some kind of C code and I found this line.

if (temp==NULL)
    while (1) ;

From my understanding, when you get into an infinite loop, you do not exit if you do not break, how does it work? it breaks if the if statement is not NULL, if so, which forces it to check the if statement again and again?

For more information, find the source code for realboy, file gboy_lcd.c

Line 304
https://github.com/guilleiguaran/realboy/blob/ed30dee751c3f78964e71930a8f87d2074362b9b/gboy_lcd.c

This is a very stable and good gameboy emulator, although for Linux

+4
source share
6 answers

- . temp NULL, while. , , .

/ (, , , , ,...), //. , , . , , ,

PS - downvotes -

+6

while, temp - NULL.

while (1) , 1!= 1, .

Allman:

if (temp == NULL)
{
    while(1)
    {
    }
}

, , if while.

+5

temp while.

+2

, /, if , while . : .

, , .

+1

, , , , "". : http://sourceforge.net/p/realboy/code/ci/master/tree/src/gboy_video.c

"vid_frame_update()". , 141. Super Game Boy "" 102.

168 ('vid_start()'), , () "temp" ( x1 x4 sgb_1 sgb_4), . , , "" .

, , , , - , ( , , - ). , -!

Thank.

+1
source

It should be easier to understand that upon successful completion, ifit enters the while loop, iterating in a continuous loop,

if (temp==NULL){
  while (1) { }
}
0
source

Source: https://habr.com/ru/post/1530692/


All Articles