Forum

> > Off Topic > "\a" Alert character in C/C++
Forums overviewOff Topic overviewLog in to reply

English "\a" Alert character in C/C++

11 replies
To the start Previous 1 Next To the start

old "\a" Alert character in C/C++

DannyDeth
User Off Offline

Quote
Hi there,

I was coding a small program just now ( bored + no one interesting on Skype ) and thought about how to alert someone using the program. I remember the old \a alert character and now I'm obsessed with trying to find out how to actually make the beep, lol.
Any answers are appreciated.

Thanks,
Danny

old Re: "\a" Alert character in C/C++

Wolf6331
User Off Offline

Quote
The alert character does only work on unix systems. But i am not to 100% sure.

on windows you need to include windows.h and use the "Beep" function:

void Beep ( int duration, int frequency );

old Re: "\a" Alert character in C/C++

DannyDeth
User Off Offline

Quote
@Lee:
1
2
3
4
5
6
#include <stdio.h>

int main(void){
	printf("\7");
	return 0;
}
Surely something like this wouldn't work.. ( compiling... )

EDIT: it isn't working. No errors.
I'm using TCC ( don't have GCC on this machine ).

old Re: "\a" Alert character in C/C++

Lee
Moderator Off Offline

Quote
Hmm, that's strange, but if ctrl+G is generating a beep, then we know that there must at least be some beep control character.

If you have python installed, can you do the following? (I'm assuming standard tty terminal)

type in a = "
hit ctrl+G
close off the quotes
type in a and enter to see what its ascii code is

Then test it by doing print a, if you get the beep, then it means we got the code right, otherwise you're probably not using a standard terminal.

old Re: "\a" Alert character in C/C++

KimKat
GAME BANNED Off Offline

Quote
Try using tput bel or alternatively /bin/echo -e "\a" in order to create a beep sound. If it doesn't work for NetBSD then possibly it may work on Linux.

old Re: "\a" Alert character in C/C++

archmage
User Off Offline

Quote
user DannyDeth has written
@Lee:
1
2
3
4
5
6
#include <stdio.h>

int main(void){
	printf("\7");
	return 0;
}
Surely something like this wouldn't work.. ( compiling... )

EDIT: it isn't working. No errors.
I'm using TCC ( don't have GCC on this machine ).


Really? It works for me. I am using GCC must be TCC.
Lol
1
2
while (true)
	printf("\7");
To the start Previous 1 Next To the start
Log in to replyOff Topic overviewForums overview