I'm trying to sum the first 4 columns of a 2D array but I keep getting the wrong answer. I'm pulling the 2D array data from a file then making a nested for loop to accomplish the math. I should be getting 1644393 for the number of visitors but I'm getting -2147483648. So I'm not exactly sure what I'm doing wrong here. Any help would be much appreciated. I'm still very new at coding also.
Sometime negative number happens is because of that it cannot hold that big of a number, like in a int it Can only hold certain amount of values. You might as well check that.
On line 14 you are reading everything into the same point in memory (which is also outside your array bounds). VISITOR_ROWS and VISITOR_COLS are the number of values for each index. Try reading into
visitors[rows][cols] instead.
That fixed it! Thanks so much, you're a life saver! My logic was that since VISITOR_ROWS and VISITOR_COLS are the same value as rows and cols it should work fine. Big time wrong on that one. Thanks again.