hello
i have a project
i need to read array from txt file and rotate the array and after this write the new array to new txt file. the arrays size is [600][800] and i have a problem when i try to read big array.
i have to read the original array to new array in my progrram and rotate my program array,and write this program array to new file. when i try to compile my program the cmd show me a massage "stack overflow". what wrong with my program?
in addition, when i try to write small arrray, the program compile my code and create new file with my array,but instead writing numbers, the program write kind of circles.
You should not use the extraction operator when working with C-strings, unless you specify the maximum number of characters to retrieve with a call to setw(). And don't forget that C-strings must have room for the end of string character ('\0').
file >> setw(4) >> CurrentPixel;
I would recommend using a const to specify the size of your array and use this const in the setw() call. Don't forget to include <iomanip> to use the manipulator setw().
And I recommend using Dynamic memory for the following: int pic[500000];
As that array is probably too big to fit in stack memory.
You are passing a variable named pic into this function, this parameter is not an array it is a pointer to an int. Since you made the array global (not static) you don't need to pass it into the function.