Amrit Singh
Amrit Singh

Reputation: 33

\a (Alarm and beep) escape sequence character not working in C language

I don't know why \a is not working. My code is working and displays in terminal. My code:

#include <stdio.h>

int main()
{
    printf("hello world\a");
    return 0;
}

My IDE: Visual Studio Code

My Compiler: Mingw gcc

Upvotes: 2

Views: 1726

Answers (1)

Acorn
Acorn

Reputation: 26066

The behavior of \a depends on the environment/terminal you use.

My guess is that Windows does not implement it or perhaps it is disabled for some reason. There is not much you can do unless you use platform-specific APIs that play a specific sound.

See How to make a Beep sound in C on Windows?

Upvotes: 1

Related Questions