Tilbage til slide -- Tastaturgenvej: 'u'  forrige -- Tastaturgenvej: 'p'  næste -- Tastaturgenvej: 'n'          errors/error-2-int.c - Et mislykket eksempel på brug af errno - i forbindelse med division.Lektion 7 - slide 10 : 25
Program 3

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <limits.h>

int main(void) {
  int x = 0, input = 0;

  errno = 0;

  /* Divide by zero */
  x = 1 / input;        /* errno is not changed by the division operator   */
                      
  if (errno){
     printf("Division failed, code: %d, message: '%s'\n", errno, strerror(errno));
     x = INT_MAX;
  }

  printf("Result is %d\n", x);

  return 0;
}