Hi, I have posted in a previous thread about this problem, but this seems not related enough to post in it. My problem is with this code:

//This is VERY simple, will just graph a y=mx+b type formula into 2 arrays.

#include <iostream>
using namespace std;

int main() {
    //Counters
    int xyMax = 10;
    int counter = -10;
    //Data banks
    int xData[xyMax];
    int yData[xyMax];
    //Vars to manipulate Y=MX+B specs
    int m = 1;
    int b = 0;
    
    for (counter; counter <= xyMax; counter ++) {
        xData[counter] = NULL; // Clear the vars
        yData[counter] = NULL; //
        }
    
    counter = -10;
     
    for (counter; counter <= xyMax; counter ++) {
        xData[counter] = counter;
        yData[counter] = xData[counter];
        cout << "(" << xData[counter] << "," << yData[counter] << ") " << counter << endl; //Read counter to make sure its not wrong...
        }
    system("pause");
    return 0;
}

I took out the use of m and b to make the program a little simpler. Besides, with them in there, I still get the same output.

The output is this:

(-10,-10) -10
(-9,16384) -9
(-8,0) -8
(-7,0) -7
(-6,2686792) -6 <-What is this?
(-5,4199624) -5 <- This?
(-4,4469696) -4 <- This?
(-3,4456450) -3 <- And this?
(-2,-2) -2
(-1,-1) -1
(0,0) 0
(1,1) 1
(2,2) 2
(3,3) 3
(4,4) 4
(5,5) 5
(6,6) 6
(7,7) 7
(8,8) 8
(9,9) 9
(10,10) 10
Press any key to continue . . .

Thanks to those who can help!
--Dylan

I believe ye' problemo might be here:

//Here you declare 'int counter = -10'
int counter = -10;

//Here you delcare an array[10] (creates elements 0 thru 9)
int xyMax = 10;   
int xData[xyMax];   
int yData[xyMax];

//Here you attempt to access array elements less than array[0]
for (counter; counter <= xyMax; counter ++) 
{        
     xData[counter] = NULL; // Clear the vars        
     yData[counter] = NULL; //        
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.