How to debug C programs from the Command Prompt?

5

I need to debug an algorithm in C but the machine I'm using does not have Code :: Blocks. What is the path for me to debug in the Windows Command Prompt?

    
asked by anonymous 16.02.2016 / 04:00

2 answers

2

To debug by Command Promp, there are only two options. Or use a debugger with no GUI such as GDB, or use text output.

This is through printf or even fprintf you can "start" the value of the variables in question, or if you want to know if you get into a condition you can put it inside to be sure. >

It's not the best, but when you can not afford it, almost everything works.

    
16.02.2016 / 17:38
1

A great program for code debugging in C is gdb, and in order to debug the code, you have to compile it with the -g parameter, which compiles the code and creates a binary file for debugging. When opening the file in gdb you use these commands:

b método/linha - coloca um breakpoint na linha ou no método desejado
r              - inicia o debug
n              - faz o breakpoint ir para a proxima linha
c              - executa até o proximo breakpoint
q              - sai do gdb
    
16.02.2016 / 06:13