if you want to write a C program for this, take a look at the manpages for file and magic and maybe at the source code for file. There isn't really an easy way of explaining it here, but each file has a 'magic number' that identifies its type. Look at the manpages and you should see what I mean. you could just call the code for file as a routine in your program.
|