To get the type of file we can execute the command
system(\"file --mime-type -b filename\");
The output displays in to terminal.But could
Hmmm the first and easiest way that comes to my mind for achieving what you want would be to redirect the output to a temp-file and then read it into a char buffer.
system("file --mime-type -b filename > tmp.txt");
after that you can use fopen
and fscanf
or whatever you want to read the content of the file.
Ofcourse, youl'll have the check the return value of system() before attempting to read the temp-file.