Basically I'm attempting to write this program but it refuses to compile, giving the error message:
Code:
Compiling and linking file: Project2.c
D:\C PROJECT\PROJECT2.C(24) : error 185 - A constant expression is required here
*** Compilation failed
Compilation failed
The program is as follows:
Code:
/*This program was written by Chris Tayler. Work started on 4/11/05*/
/*The purpose of this program is to calculate the gradient, y-intercept and the uncertainty in the gradient for a line
of best fit determined by a series of points input by the user of the program. The line of best fit is drawn using the
"least squares fitting" method.*/
#include<stdio.h>
#include<math.h>
int main (void)
{
int N; /*Declares N to be an interger*/
printf("Please enter the number of (x,y) coordinates you recorded: ");
scanf("%d",&N); /*Determines value for N (user specified)*/
printf("\nThe number of values you recorded is: %d\n\n", N); /*Prints value of N*/
int x, y; /*Declares x and y to be intergers*/
int results[N][2]; /*(attempts to) declare an array with N rows and 2 columns*/
printf("Enter your %d pairs of values in the form (x,y), pressing return after each pair\n\n", N);
return 0;
}
The error message is referring to line 24 which is:
Code:
int results[N][2]; /*Declares an array with N rows and 2 columns using the pointer *n*/
Any help on this one is appreciated, i'm still having issues with C!