Beep the PC internal speaker

Ene Uran 1 Tallied Votes 322 Views Share

Just a short little C program to send beeps to the PC internal speaker. Beep(frequency_hrz, duration_ms) is a WinAPI function as is Sleep(ms).

// simple sounds via Beep(frequency_hrz, duration_ms)
// on the PC internal speaker, a Windows Console program
// Ene Uran   Beep1.c  10/11/2006

#include <stdio.h>
#include <windows.h>   // WinApi header file

int main()
{
  puts("using winAPI Beep(frequency_hrz, duration_ms)...");
  Beep(523,500);  // 523 hertz (C5) for 500 milliseconds
  Beep(587,500);
  Beep(659,500);
  Beep(698,500);
  Beep(784,500);
  Sleep(500);    // 500 ms delay
  puts("\n\\a makes a beep on the internal speaker too ...");
  Sleep(500);
  puts("\a");
  Sleep(500);
  puts("\a");
  
  getchar(); // key wait
  return 0;
}
majicbeans 0 Newbie Poster

I am sorry I dont know html very good
How do you find all that kinda stuff out in that huge header?
Can you help out with win.cpp
I dont understand the data types except

Like longpointer lpstr
Then it has word
I can make due with hwnd (I understand how it gets declared and what it is)
they are datatypes to cprogramming

Ene Uran 638 Posting Virtuoso

The .h in windows.h stands for header, it is actually C not html. Header files are there to unclutter your code and make it easier to read and hopefully understand. So by nature, header files are hard to read and understand for a beginner.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.