at line 59-60, my program always stops working says their is an error saying I am out of the range of memory location. What does this mean and why can't I output a vector that i passed in my function. I have the right parameters don't I?
it solved my problem, but i'd like you to explain this. Why did i get the error at lines 59-60? shouldn't it tell me that the minute I try to increase the value of B?
There is no one answer to undefined behavior. Using an undefined variable as the limiter in a for loop is undefined behavior and can show up anywhere in your program. It just happened to cause problems with what seems to be an unrelated function.
Do you know what the actual number of elements were contained in your vector? No, you don't. You define an array to be 100 elements, and then likely proceed to read more than 100 elements into your vector. b in main() becomes counter in your 3 array functions.
readarray() increments a garbage value and that garbage value gets thrown into printarray() and copyarray().
GIGO, garbage in, garbage out.
It looks like you are using Visual Studio. VS in debug mode initializes variables to zero, something it doesn't do in release mode. Lots of bugs can creep in when changing that configuration.