Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use \a escape sequence

Tags:

c++

bash

escaping

I'm studying C++, using bash, and the Escape Sequences. I'm trying to do a lot of exercises to better memorize them. Now, the \a should produce a sound, like a beep.

I'm using the following code, but it seems \a doesn't work:

#include <iostream>
using namespace std;

int main ()

 {

   cout << "\a";

   return 0;

 }

Did I make any mistake? I'm only using it like the \n sequence, is this wrong? Thanks!

New details: I discovered it works on the terminal, but it doesn't work in the built-in terminal in Kate.

OS: I use Ubuntu as a guest Os using Windows 7 as host with VirtualBox. I'll post the version soon.

like image 586
Calogero Napoli Avatar asked Dec 04 '25 17:12

Calogero Napoli


1 Answers

Whether \a produces a beep or not depends on where you write it. If you run this program in a Unix terminal you'll probably get a sound. If you use an IDE or a GUI terminal emulator it might happen that you won't see or hear anything.

If you specify which terminal you're using (gnome-terminal? Apple Terminal.app?) someone might help you configuring it to play a sound...

like image 126
Joni Avatar answered Dec 06 '25 08:12

Joni