“int main (vooid)”? How does that work?

前端 未结 4 764
迷失自我
迷失自我 2020-12-22 20:31

I recently had to type in a small C test program and, in the process, I made a spelling mistake in the main function by accidentally using vooid instead of

4条回答
  •  無奈伤痛
    2020-12-22 21:27

    It's valid code, because myprog.c contains:

    int main (vooid) // vooid is of type int, allowed, and an alias for argc
    {     
      return 42; // The answer to the Ultimate Question
    } 
    

    vooid contains one plus the number of arguments passed (i.e., argc). So, in effect all you've done is to rename argc to vooid.

提交回复
热议问题