-
argh! i dont get this!
:mad:
its making me mad now
here is this code:
Code:
curr=first;
int size=curr->resp.size(); //ERROR HERE
if(curr!=NULL){
return curr->resp[RndNum(size-1)];
}
it gives an access violation error.
lets say if i type "hello" into the prompt, itll run that peice of code., it gives this error:
"Unhandled exception at 0x0041bd36 in aimoduletest.exe: 0xC0000005: Access violation reading location 0x00000014."
and cites the code where the size() function of hte vector is.
then there is this code:
Code:
curr=first;
while(curr!=NULL){
for(int i=0;i<curr->resp.size();i++){
retval+=curr->resp[i];
retval+='\n';
}
curr=curr->next;
}
that runs if you type debug into the prompt, itll return everything in that vector. i dont get why that one works, but the one above it doesnt. it returns the size fine below it, but i dunno above it
-
Take your program and write the smallest possible toy that still exhibits the problem, then post it here and we will be happy to tell you what is causing it. I'm not fond of examples that I can't play around with to make sure that I'm right without adding huge amounts of code just to get it compiled. ;)
-Prelude
-
ok, ill do that
do you just want that code involved?
heres the file:
http://users.cloud9.net/~khalid/cAIBrain.cpp
-
>actually, ill just zip the whole thing up
That would work, or just post a part of the file that describes the formatting.
-Prelude
-
the full thing is about 12mb, so i just added the main class file
http://users.cloud9.net/~khalid/AIDLL.zip
-
-
There appears to be several errors in the code but I reckon the biggest error is that you are using new all over the place and not even a sniff of a std::auto_ptr. Consider what would happen if any single use of new threw an exception. Look over your use of pointers. sometimes instead of advancing the pointer you dereference it and add 1 to the pointee. If you have a 12mb project you certainly want to think about exceptions, use auto_ptr thats exactly what its there for.
-
PS. Dont bump your threads here. Either you will get an answer or you wont. Live with it. If you bump threads you ........ people off and they will be less inclined to help you.
-
hey stoned_Coder (cool name bu the way :p), what's so greate about auto_ptr. I looked it up in the help files, but all I got was that it took care of new and delete. And I'm Like: "So what".
Plz tell me, because who knows... it might improve my code.
-
>I looked it up in the help files, but all I got was that it took care of new and delete.
You have fewer memory leaks, this is a big deal. But auto_ptr's have some interesting issues and aren't quite the pointer replacement we would like. However, they aren't a general smart pointer, so you shouldn't expect any more than the memory handling that they do.
-Prelude
-
if you want more general smart pointers look at boost libraries. They also have some good articles there on using auto_ptrs safely and correctly.
-
-
alright thanks. sorry about the bump. all of the code files etc etc are 12mb, not the EXE