Jump to content

  • Log In with Google      Sign In   
  • Create Account

#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