Thread: Help with debugging a program which needs the command prompt

  1. #1
    Registered User
    Join Date
    Sep 2010

    Help with debugging a program which needs the command prompt


    I'm a very beginner in programming and I would like to debug a program to know how it works, because its code is pretty big.

    The compilation was ok, and my problem is: the program needs the command prompt to run the executable and set its input/output files, so I have to type something like this on the prompt:

    C:\...\epanet2d input.inp report.rpt output.out

    Then, because the program needs this information, when the debugger calls the executable, it opens and closes without passing by the main routines (I guess).

    Might anyone help me with this?
    What should I do?

    ps. I'm using code::blocks

    Thanks! =)

  2. #2
    Registered User matrixx333's Avatar
    Join Date
    Mar 2009
    I've never used code::blocks before, but I did a Google search and found this:

    Project --> Set programs arguments?

  3. #3
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    London, United Kingdom
    From what I remember, you have to wrap your program in a project and have a debug build configured in order to use the debugger in the IDE.

    This should get you started:

    Debugging with Code::Blocks - CodeBlocks
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debugging strings program help plz
    By allen9190 in forum C Programming
    Replies: 1
    Last Post: 11-08-2009, 08:17 PM
  2. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  3. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

Tags for this Thread