C/Development/Beep

Материал из C\C++ эксперт
Версия от 13:22, 25 мая 2010; Admin (обсуждение | вклад) (1 версия: Импорт контента...)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Beep a sound

<source lang="cpp">

  1. include <stdio.h>

int main(void) {

 printf("\a");
 return 0;

}


      </source>


Countdown program: beep

<source lang="cpp">

  1. include <stdio.h>
  2. include <stdlib.h>
  3. include <ctype.h>
  4. include <string.h>

int main(int argc, char *argv[]) {

 int disp, count;
 if(argc<2) {
   printf("You must enter the length of the count\n");
   printf("on the command line.  Try again.\n");
   exit(1);
 }
 if(argc==3 && !strcmp(argv[2], "display")) disp = 1;
 else disp = 0;
 for(count=atoi(argv[1]); count; --count)
   if(disp) printf("%d\n", count);
 putchar("\a");  /* this will ring the bell */
 printf("Done");
 return 0;

}


      </source>