(a) your Array (I would tell you the line in your code if you had used the "code"-tags) has 12 fields. The first is named Array[0], the last is Array[11]. You are trying to access Array[12] (and salesArray[13]):
1 2
|
for (int index =0; index <= 12; index++)
Array[index] = salesArray[index+1];
|
index becomes 12 (you should write ...index < 12..., not <=) and then you add one in salesArray[index+1] (which , I presume, has 12 fields, too).
This is the actual cause for the error you get.
(b) C++ contains a library, the STL (Standard Template Library), in which containers, iterators and algorithms are defined. Learn how to use the stl, it will reduce the ammount of work you have to do by ~80%. It is contained in the C++ standard, so it is available on every platform and every C++ compiler.
What I suggested was that you substitute your C-style array Array[12] (and the parameters like double array[]) by std::vector<double>, thereby using the container "vector" (which behaves exactly like an array, but is "smarter" - e.g., it has a function "size()" which returns the number of elements in the vector). Then I suggested that you use algorithms of the stl, namely accumulate and nth_element, which sum the contents of any container or writes the nth element on the position it would be if the sequence was sorted, respectively (the median would be the middle element, thus the parameters I specified).
Since the containers are different and the algorithm is not re-written for each container, iterators are used as "glue" between containers and algorithms in the stl (in the example above, pointers are used as iterators). However, this is somewhat complicated for in the beginning and you should read a book to learn it properly. I reccommend the C++ Primer as a first reading (just seach the name on bookzilla.org or alike).