Bonjour à tous,

Peut-on produire un son en C?

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
#include <stdio.h>
#include <dos.h>
#include <unistd.h>
 
void whistle(void);	//The devious prototype
 
void main()
{
	printf("Press any key to hear annoying whistle:");
	sleep(1);
	whistle();
	printf("\nYikes!\n");
}
 
void whistle()
{
	int x;
 
	for(x=880;x>440;x-=5)
	{
		sound(x);
		sleep(1);
	}
	nosound();
}

whistle.c:22:3: warning: déclaration implicite de la fonction «*sound*» [-Wimplicit-function-declaration]
sound(x);


whistle.c:25:2: warning: déclaration implicite de la fonction «*nosound*» [-Wimplicit-function-declaration]
nosound();
^~~~~~~

/tmp/ccRluwWG.o:whistle.c:(.text+0x4d)*: référence indéfinie vers «*sound*»
/tmp/ccRluwWG.o:whistle.c:(.text+0x69)*: référence indéfinie vers «*nosound*»
collect2: error: ld a retourné le statut de sortie 1
sound();
nosound();

Merci de votre attention;

JPD