c - expression did not evaluate to a constant ERROR code -
so trying learn c , trying make code sort of array's elements lowest highest, it's not complete wanted see random numbers printed.
anyway, getting error e0028 & c2131 (visual studios) says "expression must have constant value" & "expression did not evaluate constant." int goals[howmany];is vs telling me have error
int main() { int i, temp, swapped; int howmany = 10; int goals[howmany]; (i = 0; < howmany; i++) { goals[i] = (rand() % 25) + 1; } printf("original list\n"); (i = 0; < howmany; i++) { printf("%d \n", goals[i]); } return 0; } this how code written out in tutorial watching , using code:blocks. know 2 compilers can different hoping can let me know what's going on or how fix this.
visual studio doesn't support variable length arrays. c little tricky, , compiler/flags use matters. example, if compile gcc compiler, using -std=c99 flag allow run code no errors (since -std=c99 supports variable length arrays).
i'm not sure how compilation in visual studio works, that's problem. don't c programming in vs reason. it's easier me use vim, , compile @ command can specify compiler settings.
Comments
Post a Comment