I need to open a file in C but I want to make sure that it is a ASCII text file before I open it.
What is the best way to accomplish this in C? (UNIX)
This is the only way I can think of:
Call the shell command "file filename > tempfile" from my C code and then read tempfile for the output from the command. (is there a way to avoid the step of creating tempfile and returning stdout from the file command directly into my C prog?)
Anyone know a better way?