简体   繁体   English

在 C++ 中使用“\a”发出哔声在 Mac 上的 xcode 中不起作用

[英]Making a Beep with “\a” in C++ not working in xcode on mac

I am making a program that makes a beep noise in Xcode on a MacBook pro.我正在制作一个程序,它在 MacBook Pro 上的 Xcode 中发出哔哔声。 The speakers on my computer are on and the volume is on max yet I can't hear anything.我电脑上的扬声器开着,音量开到最大,但我什么也听不见。 This is my program, can you please tell me why it is not working?这是我的程序,你能告诉我为什么它不工作吗?

int main(int argc, const char * argv[]) {
    std::cout << "\a";
    return 0;
}

Is there a way to make a beep noise using only "\a"?有没有办法只使用“\a”来发出哔哔声?

Stop at any step if it works!如果有效,请在任何步骤停止!

  1. Go to Terminal > Preferences > Settings > Advanced and tick the Audible Bell option. Go 到Terminal > Preferences > Settings > Advanced并勾选Audible Bell选项。

  2. Also make sure that in System Preferences > Sound , the slider for Alert Volume is not on its leftmost setting.还要确保在System Preferences > Sound中, Alert Volume的 slider 不在其最左侧设置。

  3. Try restarting your system if you've updated it.如果您已更新系统,请尝试重新启动系统。

  4. Try running the generated executable on terminal instead of XCode's integrated terminal.尝试在终端而不是 XCode 的集成终端上运行生成的可执行文件。

  5. Check if terminal beeps on this command: $ printf \\a .检查终端是否在此命令上发出哔哔声: $ printf \\a

Even after all these if you don't get any beep sound then go through the steps mentioned in this solution .即使在所有这些之后,如果您没有听到任何哔声,那么 go 通过此解决方案中提到的步骤。 Or ask it on Apple SE or Apple Discussion Forums.或者在Apple SE或 Apple 论坛上提问。

You have to do this: Go to Terminal > Preferences > Settings > Advanced and tick the Audible Bell option.你必须这样做:Go 到终端 > 首选项 > 设置 > 高级并勾选响铃选项。 See if this works!看看这是否有效!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM