| matitou (3) | |
|
Hi, I'm new to this forum and i have a problem in C++. The code is not very long but i feel that the easiest way to show you the bug is by adding the codeblock project to the thread. http://www.2shared.com/file/AUQen22I/Projet_C.html The error is at the line 75 of the main.cpp . When i run the project, you can see that the method is succesfully called many time. But there is always one time it doesn't work. I tried to localize the segment fault and it's just when the method is called. You can access the AgentFondamental[i] attribute so it's not an invalid case of the vector. It print 1 before entering the method, but don't print a as it's asked line 46 of the file Agents.cpp. I hope i respect the tos of the forum and thank you for your time. (By the way i'm french so some of the variable are in french, sorry :/ ) | |
|
|
|
| matitou (3) | |||||
Here is a summarize of the problem :
So when i execute the project, i got a segment fault when i call the method demander_ordre. The problem is that it work for a few times but when it bug, it print 1 as it's asked line 2 of the sample. Here is the method :
When the segment fault occur, i don't get the "a" i asked to print line 2 of this sample. I thought it was the object i that wasn't in the range [0;AgentFondamental.size()[ but i can access the attribute of the object AgentFondamental[i] ... | |||||
|
|
|||||
| ne555 (4385) | |||
|
_ Respect the case of the files _ Read the warnings float X = ((float) rand()) / (RAND_MAX + 1); //integer overflow > i don't get the "a" i asked to print line 2 of this sample stdout is buffered. If you want to debug with allusive messages, use stdcerr instead. I get out of bounds in main.cpp:169 (_GLIBCXX_DEBUG)
Apart, ¿why those castings? ¿why don't make the sizes unsigned too? * When you share code, don't include binaries or object files, they are useless | |||
|
Last edited on
|
|||
| matitou (3) | |
|
Thank you, really. I've removed the castings and made the sizes unsigned. I would like to know how did you get the warning for the integer overflow. Again, thank you for your help and your time | |
|
|
|