Do not use increment, decrement, or compound assignment operators as subexpressions i
From what i too have been studying is that eg; static const int k = 3;
Yes you can initialize k but you can not assign nor ++ or -- it. Even though a variable has been qualified with const, it still cannoit be used to specify an array size in another declaration.
Just a little FYI ...
Re: Do not use increment, decrement, or compound assignment operators as subexpressio
Quote:
Originally posted by correlcj
From what i too have been studying is that eg; static const int k = 3;
Yes you can initialize k but you can not assign nor ++ or -- it.
Of course you can't. You've declared it const. This goes without saying. You cannot modify a constant variable.
As for your second part, I believe with the latest version of the standard you can. Then again, I've never bothered to read the standard, so I may be off there.
Also, it depends on your compiler. For example, with gcc, you can do the following:
Code:
#include <stdio.h>
int main ( void )
{
int x = 5;
{
char array[x]={0};
int y;
for( y = 0; y < x-1; y++ )
array[y]='a'+y;
printf("%s",array);
}
return 0;
}
And it will compile and execute.
Quzah.