•      Sign In
• Create Account

Need scary sound effects or creepy audio loops for your next horror-themed game? Check out Highscore Vol.3 - The Horror Edition in our marketplace. 50 sounds and 10 loops for only \$9.99!

### #ActualÁlvaro

Posted 12 February 2013 - 08:18 AM

Álvaro, on 11 Feb 2013 - 13:49, said:
Actually, I don't think this is true in C. I couldn't get this to work:

const int N = 10;

struct S {
int i[N];
};


That would definitely be a good case to use them. (I didn't say never to use them.) I think you can still use const values in stack arrays though. [...]

Sort of. C99 has variable-length arrays, which is why it will work if you use a const' variable as the size of an array on the stack.

### #1Álvaro

Posted 12 February 2013 - 08:18 AM

Álvaro, on 11 Feb 2013 - 13:49, said:
Actually, I don't think this is true in C. I couldn't get this to work:

const int N = 10;

struct S {
int i[N];
};


That would definitely be a good case to use them. (I didn't say never to use them.) I think you can still use const values in stack arrays though. [...]

Sort of. C99 has variable-length arrays, which is why it will work if you use a const' variable as the size of an array on the stack.

You can use any variable as the size of an array in the stack.

PARTNERS