-8

Method 1: works

const int MAX_STRING = 256;

int main(void) {
    char buffer[MAX_STRING];
}

Method 2: Does not work - compilation error.

#define MAX_STRING 256;

int main(void) {
    char buffer[MAX_STRING];
}

What is the reason of the different behavior of those codes? Are those both MAX_STRINGs not constants?

MD XF
  • 7,860
  • 7
  • 40
  • 71
RonanMacF
  • 309
  • 2
  • 9

0 Answers0