Funny things happening outside of function

Hi again all,

This time i'm having trouble in returning a value from a class function. The function is supposed to work out the euclidian distance between two points i.e. sqrt( (x1-x2)squared + (y1-y2)squared). The distance i'm working out is over 10 points. When I was running the function in MSDOS it worked fine, however now that i'm tyring to run the program in MFC windows things aren't quite working.

Here is the function for calculating the length:

Code:

`int CLine::SectionLength(int m_XYCoOrds[][2])`

{

int TotalLength =15;

int SectionLength =0;

int Xvariance = 0;

int Yvariance = 0;

for(int i=0;i<8;i++)

{

variance = (m_XYCoOrds[i][0] - m_XYCoOrds[i+1][0]);

Yvariance = (m_XYCoOrds[i][1] - m_XYCoOrds[i+1][1]);

SectionLength = (sqrt( (Xvariance*Xvariance) + (Yvariance*Yvariance)));

TotalLength = TotalLength + SectionLength;

}

return TotalLength;

}

where m_XYCoOrds is a 2d array with i referring to the current point (0-9) and [i][0] being x, [i][1] being y.

The TotalLength value returned is stored in the object under the name m_Length.

When I try and see what the value is i call this in the View.cpp file

Code:

`CString test; //string to show the total length number`

int test3 = pDoc->LineArray[0].m_Length;//get the first lines length

test.Format(_T("test length is %d",test3));

this has been producing the value -842150451

I don't think its just a problem with the test.Format line as I can access other data members in the class that are initialised fine.

As a quick test before wasting anyones time I set the function to just return the value 15, however m_Length was still showing -842150451. Can anyone tell me where this magic number has come from.

Any help whatsoever is again greatly appreciated.

Cheers

Dylan