segmentation fault in program at run time
I am making a program to do a breadth first search.
The code which I am posting here just makes a que of the nodes visited in a binary tree in inorder fashion,so this implementation is not yet complete. While developing I got a segmentation fault which I was not able to understand why I am getting so I am posting since the tree of same program (without BFS) is working. Code:
|
"Use the source, Luke":
Assuming you're using GCC or G++: 1. (Re)build your code with "-g" (enable debugger) 2. Run your program in gdb 3. Type "where" to get a stack traceback when the problem occurs PS: Here's a good tutorial on using GDB: http://www.unknownroad.com/rtfm/gdbtut/gdbtoc.html |
The problem was that tree could not be travelled.
while(0) any thing inside this statement was not executing. I could not understand why. I changed while(0) to while(1==1) and it worked, |
Quote:
|
Frankly, you've just given a very good reason why it would be a good idea to familiarize yourself with a debugger (if you haven't already).
ALSO: 1. As you know, this means "while (FALSE)": Code:
while (0) Code:
while (1 == 1) // Comparing any number with itself is always TRUE Code:
// Poor IMHO ... |
All times are GMT -5. The time now is 05:38 PM. |