Runtime Error

Hi i am running Visual c++ 2008 and im writing a program that pretty much just organizes names of people and their numbers. When i run it i get this weird weird error. It says "This application has requested it to terminate it in an unusual way." Im stuck and i dont know what to do. I cant figure it out with the debugger. I am pretty sure the error is in my hyphens function. This is what it looks like
1
2
3
4
5
6
7
8
9
void Hyphens(string Numbers[], int size)
{
	for(int i = 1; i < size; i++)
	{
		Numbers[i].insert(3, "-");

	}

}


Now i know its in there because my code was working exactly how i wanted it to before i made this function. We are using the #include<string> class. Any tips please. Thanks!

Array indices start at 0, not 1.
Changed it to zero. Still giving me the same issue.
Your Hyphens function now looks right to me. The problem probably lies elsewhere.

Can you post more code?
sorry i needed to take my code off
Last edited on
hey i got it! It was in my Hyphens program. I needed to change from size to (size -1). i dont know why exactly. if you can explain that that would be helpful. Thanks!
If an array has say, 4 elements then the subscripts of the array are 0,1,2,3
If your check was < size, then changing it to size - 1 sounds to me like your size variable is off by 1.
Topic archived. No new replies allowed.