954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

unhandaled exception,0X000005:access violation

Hi,
I get this message when the program shold exit the main function. I think that the problam could be in that function (that is being called from main):
void scanFileToMat( ifstream mFile,int arr[43][43])
{
string m ,s;
int pos;
double sign;
int col, value;
getline(mFile,m,')');
while(!mFile.eof())
{

mFile>>sign;
arr[numSV][42]=sign>0;
getline(mFile,m,'\n');

while(m.length())

{ pos=m.find_first_of(':');
s=m.substr(0,pos);
char *charArr=new char[pos+1];
for(int i=0;i

michal
Newbie Poster
1 post since Oct 2004
Reputation Points: 10
Solved Threads: 0
 

>But I cant see where!
That's because you're doing so much that could cause it! An access violation is when you access memory outside of your address space. This is most often caused by writing to uninitialized memory (through a pointer) or by overrunning the boundaries of an array (either statically or dynamically allocated).

If you don't have a good debugger, litter your code with debug statements that tell you exactly what the limits of your arrays are and what the values of the indices you're using are. Then print the value of your pointers to ensure that they're pointed where you want them to be, and pay careful attention to your dynamic allocation. An off-by-one error there will usually show up when the memory is reclaimed. The memory manager is a fragile beast and you must be especially careful.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You