learning the C programming language and reading the documentation with Xcode 13.2 open and a Command-Line Tool project in front of me.
Reading this, in the Declarations/Arrays/Variable Length Arrays section:
{
int n = 1;
label:
int a[n]; // re-allocated 10 times, each with a different size
printf("The array has %zu elements\n", sizeof a / sizeof *a);
if (n++ < 10) goto label; // leaving the scope of a VLA ends its lifetime
}
And copying it in Xcode, inside the main
function, it just gives me the "Expected expression" error next to the int a[n];
line. I tried to put this into a separate function but this was not the solution.
What is going wrong here?
Thank you