I created this program to help myself learn how to use and manipulate arrays. The program compiles fine, but when I run it it says, "ArrayTestOne.exe has stopped working, windows is looking for a solution." It doesn't do anything else.
Here's the code:
Have you tried debugging it? It looks like you are allocating an array of 0 elements and then writing past the array bounds. You may be incrementing your counter but you are not changing the size of the array.
Your solution would be to figure out how much space you need up front and allocate and array of that size.
Thanks, I actually just realized that myself. I'm now going through the process of re-doing the entire program, to add in a little more functionality, and actually fix the original problem. I was wondering though, is it possible to call the elements of an array, based on the string used inside of it? For example, and this is just a quick example:
1 2 3 4
//Other stuff here
string ArrayZero = "This";
//Other stuff here
Array[0] = ArrayZero; //I assume this part puts the value of ArrayZero into Array[0]
So, could I reference Array[0], as Array[ArrayZero], or as (Array[This], or Array["This"])?
Using the name or contents of the string. Sorry, this is my first time actually working with arrays. It's a little confusing.