How to make a beep

I am very new to coding. C++ is my first language and I've been learning for a few weeks now. I am trying to output a beeping noise and I've read about \a, \7, ^G, etc. and none of them work for me. It only outputs an upside down ?.
I am using a MacBook Pro, OSX 10.8.4. My IDE is XCode.
I was wondering is there is a simple function I can use to make a beeping noise. I need to be able to control the length of time that it beeps for, and it would be preferable, but not necessary, to be able to control the frequency of the sound.
I doubt most notebooks even have a PC speaker. But anyway, you could try this:

http://stackoverflow.com/questions/4447166/how-to-use-pc-speaker-in-linux
I also have a speaker hooked up to an arduino. Is there a way to send different time periods of voltage to the arduino through C++ to make it sound?
Topic archived. No new replies allowed.