-1
int NumOfCourses = 0;
int i = 0;
int total = 0;

int main()
{
printf("How many courses");
scanf_s("%d", NumOfCourses);
for (i = 0; i < NumOfCourses; i++)
{
    total += i;
}

int Courses[i][3];

It will not let me use i as a value for the rows of my array because it is not a constant.

1 Answers1

1

The construct you used is called Variable Length Array (VLA). It is mandatory for C99 compiler and optional for C11 compiler. All older versions of C (K&%, C89, C90, C95) do not know VLA. So it depends, which standard your compiler follows. Frequently, compilers know more than one version, and you can select the standard. Try the -std=c99 option.

Matthias
  • 8,018
  • 2
  • 27
  • 53