Thread: DEV-C++ made program crashes when run from outside the ide

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    29

    DEV-C++ made program crashes when run from outside the ide

    When I click on the compile/run icons in the upper left corner of the devcpp ide my program runs fine. But when i run my program from outside the editor it crashes by just double clicking on it (the exe icon), it crashes.

    I think I know where the problem is but I don't understand it. My program reads text files and then acts upon what values it finds in them. When I hard code all the values in and completely comment out the readfile code the program runs fine when I double clicking on the exe icon.

    I don't understand why using fstream only works for me if i click the compile&run/run icon in the editor and crashes if i try to run the program without the editor.

    Thank you for reading this and your help/comments.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    When you run your program from Dev-C++ the "current" directory is probably different than when you double click on the executable. So, it is possible that the file cannot be found when you couble-click but it can be found when you run from the IDE.

    Try using a full path to the input file and see if it still has an issue.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    And write your program so that it doesn't crash when it can't open the file. Make it write a proper error message instead.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Registered User
    Join Date
    Oct 2003
    Posts
    29
    thank you for your help. when I added std::ios::in it worked fine

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. HttpSendRequest crashes program
    By Anubis208 in forum Windows Programming
    Replies: 8
    Last Post: 10-15-2008, 01:58 PM
  2. How to time how long a program takes to run?
    By advancedk in forum C Programming
    Replies: 2
    Last Post: 08-18-2008, 07:50 PM
  3. Program crashes and memory leaks
    By ulillillia in forum Tech Board
    Replies: 1
    Last Post: 05-15-2007, 10:54 PM
  4. Help me with my basic program, nothing I create will run
    By Ravens'sWrath in forum C Programming
    Replies: 31
    Last Post: 05-13-2007, 02:35 AM
  5. Program crashes and I can't figure out why
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 09-19-2001, 05:33 PM