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
See the man page of system: It does not return the output of the command executed (but an errorcode or the return value of the command).
system
What you want is popen. It return a FILE* which you can use to read the output of the command (see popen man page for details).
popen
FILE*