Interview Hello World explanation

后端 未结 5 863
名媛妹妹
名媛妹妹 2021-01-30 05:57

This classic ioccc entry is a Hello World program written in C. Can anyone please provide an explanation of how it works?

Original code (syntax highlighting intentionall

5条回答
  •  走了就别回头了
    2021-01-30 06:09

    Yet another interview question that seems to reflect more on the interviewer than the interviewee. Key issues here: * j is always 0 (('-' - '-') == 0) * p is always 1 (('/' / '/') == 1) * i (in the read function) is (i++ + "hello world") == the i'th character in hello world (then increment i)

    Thus the read function becomes

    read(0, NextChar, 1)
    {
      write(1, NextChar , 1);
    }
    

    The only other bit is the commutativity of the []operator in the for loop.

    Understanding and parsing this kind of code is really valueless imho.

提交回复
热议问题