Ok, so i have read about it on the web before posting this and i have changed it time and time and it still does not work. I am using Dev-C++ (as my instructor insisted) and it complies correctly but does not run. Here is the part of my code that does not work:
int main(){
float plotPoints [20][20];
float value = 0.0;
for ( int y = 0; y <= 20; y++ ){
for ( int x = 0; x <= 20; x++ ){
x = x - 10;
y = y - 10;
value = ( sqrt( pow( x, 2.0 ) + pow( y, 2.0 ) ) + 0.001 );
plotPoints [x][y] = ( (sin(value)) / value ); // THE ERROR OCCURS HERE
}
}
for ( int y = 0; y <= 20; y++ ){
for ( int x = 0; x <= 20; x++ ){
cout << plotPoints [x][y];
}
}
return 0;
}
i know it is a issue with the pointer and memory, i just dont understand how to fix it.
Even if the problem with accessing arrays with negative values didn't exist in the program, which turbo pointed out you'd still have a continuous for loop with no chance of exit. The x variable used for the for loop is initialized to 0, and immediately changed to -10. If the program didn't crash, how would the loop ever exit?