On Fri, Feb 26, 2010 at 05:19:24PM -0800, Michael Robinson wrote:
> I'm trying to write a simple C program to open a text file with
> temperature data in it, extract the highest, the lowest, and the
> last temperature, and write that information to another text file.
>
> How in C do I verify that the files I'm working with are text files?
> Specifically since I don't allow clobbering, I'm worried about the
> input file.
You read a bytestream and see if it matches your expected range of
characters. if it doesn't match you handle the unexpected input
in whatever manner you deem appropriate for your program and shut
down.
> I'm thinking there is a UNIX file command which I should be able
> to call from inside the C program, but is there a better way?
There is such a program, but you're writing something in C.
If you wanted to use such a program you'd be writing a shell script.
--
Michael Rasmussen, Portland Oregon
Trading kilograms for kilometers since 2003
Be appropriate && Follow your curiosity
http://www.jamhome.us/
The Fortune Cookie Fortune today is:
Q: What do you call a half-dozen Indians with Asian flu?
A: Six sick Sikhs (sic).
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug