User Tools

Site Tools


c:error_checking

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
c:error_checking [2016/07/02 00:44] – created peterc:error_checking [2020/07/15 09:30] (current) – external edit 127.0.0.1
Line 2: Line 2:
  
 <code c> <code c>
-    #include <errno.h> +#include <errno.h> 
-    #include <stdio.h> +#include <stdio.h> 
-    #include <stdlib.h> +#include <stdlib.h> 
-    #include <string.h>+#include <string.h>
  
-    int main() +int main() 
-    +
-            FILE *fp; +  FILE *fp; 
-            char errmsg[200];+  char errmsg[200];
  
-            fp = fopen("Nofile", "r"); +  fp = fopen("Nofile", "r"); 
-            if (fp == NULL) { +  if (fp == NULL) { 
-                    perror("fopen"); +    perror("fopen"); 
-                    /* +    /* 
-                     *  strerror_r(errno, errmsg, sizeof(errmsg)); +     *  strerror_r(errno, errmsg, sizeof(errmsg)); 
-                     *  printf("fopen: %s(%d)\n", errmsg, errno);  +     *  printf("fopen: %s(%d)\n", errmsg, errno);  
-                     +     
-                     */ +     */ 
-                    exit(EXIT_FAILURE); +     exit(EXIT_FAILURE); 
-            +  
-            return 0; + 
-    }+  return 0; 
 +}
 </code> </code>
c/error_checking.1467420253.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki