Any idea why this is giving me a segmentation fault ?
It prints the first three well and then just gives me a segmentation fault :o
printf("\t\t EDGE %d %d \n",aux2->numerovertice,aux2->a->destino->numerovertice);
printf("\t\t EDGE %d %d \n",aux2->numerovertice,aux2->a->prox->destino->numerovertice);}
Yes, you compile it with debug
gcc -g prog.c
Then you load the program into a debugger
Then you run the code and wait for the crash.
Then you do things like
until you find the garbage pointer.
Thanks Salem but how do I run the code ?
Sorry, I've never used gdb before.
Type 'run' into the GDB prompt.
Originally Posted by DeanWinchester
Type 'man gdb' for other commands.
Really, you don't say.....
GNU gdb (GDB) 7.1-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
List of classes of commands:
aliases -- Aliases of other commands
breakpoints -- Making program stop at certain points
data -- Examining data
files -- Specifying and examining files
internals -- Maintenance commands
obscure -- Obscure features
running -- Running the program
stack -- Examining the stack
status -- Status inquiries
support -- Support facilities
tracepoints -- Tracing of program execution without stopping the program
user-defined -- User-defined commands
Type "help" followed by a class name for a list of commands in that class.
Type "help all" for the list of all commands.
Type "help" followed by command name for full documentation.
Type "apropos word" to search for commands related to "word".
Command name abbreviations are allowed if unambiguous.
Hmm, thanks a lot, gonna start using this! :D
My magic 8-ball says it might be this:
But really, that's just a guess.