#else Directive

This page was translated by a robot.

The #elsedirective initiates the start of conditional compilation if the preceding condition was not met. The block of code from the preceding #if, , #elif, #ifdefor #ifndefdirective completes.








Small array
#include <stdio.h>
#define ARRAY_SIZE 1000

int main(){
  #if ARRAY_SIZE > 100000
    printf("Large array\n");
  #else
    printf("Small array\n");
  #endif
  return 0;
}

Details

A conditional compilation does not necessarily have to #elsecontain a directive.

The #elsedirective designates the last code block of the conditional compilation, after that no further #elifdirectives can occur at the same level, the conditional compilation must be terminated with the #endifdirective