程序发出蜂鸣声,即使它在任何地方都不包含 \a

Program makes a beep sound even though it doesn't contain \a anywhere

即使我没有在我的代码中添加 \a,我的电脑还是发出了哔哔声。为什么?

节目:

#include <stdio.h>
#include <limits.h>
#include <float.h>
#include <stdlib.h>

#define START_CHAR ' '
#define END_CHAR 'DEL'

int main(void)
{  /* This code prints characters on keyboard.*/

   /* declaration */

  int char_code;

  for (char_code=(int)START_CHAR; char_code<=(int)END_CHAR; char_code=char_code+1)
    printf("%c", (char)char_code);

  printf("\n");

  return(0); 
}

'DEL' 不是有效的字符常量。它最终等于 4474188。并且由于您将 char_code 定义为 int,因此循环从 32(space 的 ASCII 代码)到 4474188。因此它循环完整字符集多次。

您应该改用 0x7F