문제

I just started learning C++, and I came across an escape sequence that must make a beep. When I compile it and run, i don't hear a beep for some reason. Here is the code:

#include <iostream>
using namespace std;

int main(){
  cout << "Cool\a\nHey man!\n";
  return 0;
}

The sequence \a doesn't work. Any help would be appreciated. Thanks!

도움이 되었습니까?

해결책

The equivalent of that is working for me. First off, is your terminal beep working? That may be hard to test; you could try printf '\a' from the command-line.

Also, try running the output through a hex dump tool; either of these should do the trick:

xxd
od -tx1

Verify the bell is coming out as a character with value 7.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top