Q. How can I open audio files from the program?
Q. How can I open audio files from the program?
The fopen() command does that, e.g.:
Code:FILE *fp; fp = fopen("myFilename", "rb"); //opens the file myFilename, for reading, in binary mode (instead of text), returning the file's address to the FILE pointer, fp. if(fp == NULL) { //there was an error, the file didn't open printf("\n File open error (myFilename)\n"); exit(1); // quit the program } //rest of your code.
Check out Wotsit.org for some file format specifications, and say hello to endianness...for instance, .au file data is stored as big-endian, whereas .wav file data is little-endian.
If you're wanting to play the file, you should search for FMOD, BASS, audiere, OpenAL, some library that plays and manipulates sound files.