added error checking on file open
authorBrian Paul <brian.paul@tungstengraphics.com>
Wed, 29 Mar 2000 17:56:02 +0000 (17:56 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Wed, 29 Mar 2000 17:56:02 +0000 (17:56 +0000)
progs/demos/geartrain.c

index 91c3411d7c96715ff85db81ac3d55cb1ed70c6dc..7c42aeb3d5211928ae0f51730c730163194ceca7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: geartrain.c,v 1.2 2000/03/22 23:14:54 brianp Exp $ */
+/* $Id: geartrain.c,v 1.3 2000/03/29 17:56:02 brianp Exp $ */
 
 /*
  * Geartrain simulation 
@@ -145,6 +145,11 @@ getdata (char filename[])
     int gear_count = 0, axle_count = 0, belt_count = 0, i;
     
     mainfile = fopen (filename, "r");
+    if (!mainfile) {
+       printf("Error: couldn't open %s\n", filename);
+       exit(-1);
+    }
+
     do
     {
        Clear_Buffers ();