#include<stdio.h>
#include <file.h>

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

FILE *fp;
char s[100];
int i;
//char exit

    if((fp=fopen("Allah ya isa.mp3","rb"))==NULL) //Open file and read on binary mode
       { 
         printf("Could not open the file\n");
       //  exit(1);
    }

fclose(fp);


 }


#include<stdio.h>``

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

FILE *fp;
char s[100];
int i;
//char exit

    if((fp=fopen("Allah ya isa.mp3","rb"))==NULL) //Open file and read on binary mode
       { 
         printf("Could not open the file\n");
       //  exit(1);
    }

fclose(fp);


 }

Recommended Answers

All 4 Replies

You are in fact opening the file correctly, but that won't do you much good unless you have a codec to decode the data with, I am afraid. We'd have to know what kind of system you are using (e.g., Windows, Linux, MacOS, FreeBSD, etc.) and what kind of libraries you have, in order to be able to even begin giving you any suggestions.

BTW, MP3 is not an open format, and while most systems have some form of MP3 codec to use, it might be easier if you could use files that are in an open format such as Vorbis or FLAC. I know you may not have a choice in the matter, but if you do, try using Ogg Vorbis.

commented: thanks i'll try it. +0

If you use windows api...

ShellExecute(NULL, "open", "Path\\file.mp3", NULL, NULL, SW_SHOWNORMAL);

While that would indeed play the file, I'm not sure that this accomplishes quite what the OP had in mind. It sounds as if he intended to actually play the file within the program itself, not shell out to a different program to run it. Also, I didn't want to assume he was running Windows.

If on Windows then call PlaySound(). I don't know the *nix equivalent, or even if there is one.

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.