Hmmm, the first and easiest way to figure out what you want is to redirect the output to a temporary file and then read it in the 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 contents of the file.
Of course, before trying to read the temporary file, you will have to check the return value of system () .
source share