Dev C++

This is a discussion on Dev C++ within the C++ Programming forums, part of the General Programming Boards category; Hello, Anyone here experience with Dev c++ ? Just installed version 4.9.9.2 with Windows XP operating system service pack 3 ...

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    73

    Dev C++

    Hello,

    Anyone here experience with Dev c++ ? Just installed version 4.9.9.2 with Windows XP operating system service pack 3 . I installed it in the C drive. It seems that the program is compling without any error but not running. A windows just came for a second and then disappeared and i wont be able to see my results. Any solution for that? I tried to run this program and MS visual studio it runs well.

    regards-
    lemon

    Code:
    #include <iostream>
    using namespace std;
    
    class Ratio
    { public:
        void assign(int, int);
        double convert();
        void invert();
        void print();
      private:
        int num, den;
    };
    
    int main()
    { Ratio x;
      x.assign(22,7);
      cout << "x = ";
      x.print();
      cout << " = " << x.convert() << endl;
      x.invert();
      cout << "1/x = ";  x.print();
      cout << endl;
    }
    
    void Ratio::assign(int numerator, int denominator)
    { num = numerator;
      den = denominator;
    }
    
    double Ratio::convert()
    { return double(num)/den;
    }
    
    void Ratio::invert()
    { int temp = num;
      num = den;
      den = temp;
    }
    
    void Ratio::print()
    { cout << num << '/' << den;
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,779
    Quote Originally Posted by chaklader
    It seems that the program is compling without any error but not running. A windows just came for a second and then disappeared and i wont be able to see my results. Any solution for that?
    Read the FAQ on How do I stop my Windows Console from disappearing everytime I run my program?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    2,859
    you also need a different IDE. Dev-C++ hasn't been updated since 2004, and comes with a compiler even older than that (2003, I think). Eclipse, NetBeans, Visual C++ Express, and Code::Blocks are all MUCH better options.

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    73
    I installed Visual C++ Express but still have the same problem. Anyone could explain me how to compile and run Dev c++from cmd ?
    I installed in C:\Dev-Cpp and my files are in D:\Book's\Schaum's Programming with C++\Source code\Chapter 8_Classesin the folder.

    Say, a file name is Ex1001.cpp. How to run it from cmd ? I need it to know as it will be used in school.


    thanks in advance for your help.

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    2,949
    Open up an cmd prompt window using cmd.exe
    change the current directory correct folder
    type the command to run your executable file

    [WIN] + R
    type "cmd.exe" in run box.


    example below
    Code:
    cd /d d:\projectfolder
    Ex1001

  6. #6
    Registered User
    Join Date
    May 2010
    Posts
    73
    So, now the .cpp is opened with this command -

    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    C:\Documents and Settings\C A Arefe>D:

    D:\>cd D:\Book's\Schaum's Programming with C++\Source code\Chapter 8_Classes

    D:\Book's\Schaum's Programming with C++\Source code\Chapter 8_Classes>Ex1001.cpp


    D:\Book's\Schaum's Programming with C++\Source code\Chapter 8_Classes>

    How to compile and run it from cmd ?

  7. #7
    Rat with a C++ compiler Rodaxoleaux's Avatar
    Join Date
    Sep 2011
    Location
    ntdll.dll
    Posts
    201
    [STRIKE]with Visual C++, i don't know, so google it[/STRIKE]. If you have Code::Blocks (which I think is the better choice), you'd be using MinGW so...

    g++ Ex1001.cpp -o Ex1001.exe

    I got curious.

    cl.exe /EHsc Ex1001.cpp
    Last edited by Rodaxoleaux; 11-01-2011 at 12:16 PM.
    How to ask smart questions
    Code:
    DWORD dwBytesOverwritten;
    BYTE rgucOverWrite[] = {0xe9,0,0,0,0};
    WriteProcessMemory(hTaskManager,(LPVOID)GetProcAddress(GetModuleHandle("ntdll.dll"),"NtQuerySystemInformation"),rgucOverWrite,5,&dwBytesOverwritten);

  8. #8
    Registered User
    Join Date
    May 2010
    Posts
    73
    Thanks for your post. But, still it is not working. The cmd now is like:

    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    C:\Documents and Settings\C A Arefe>D:

    D:\>cd D:\Book's\Schaum's Programming with C++\Source code\Chapter 8_Classes

    D:\Book's\Schaum's Programming with C++\Source code\Chapter 8_Classes>g++ Ex1001
    .cpp -o Ex1001.exe

    D:\Book's\Schaum's Programming with C++\Source code\Chapter 8_Classes>


    No output after putting your code. I also set the PATH using this webpage: C++: howto compile with Dev-C++

    So, the PATH is now: C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin;C:\Dev-Cpp\bin

    it is because MS Visual studio was installed before. The code of the file I'm trying to execute is:

    Code:
    //  Programming with C++, Second Edition, by John R. Hubbard
    //  Copyright McGraw-Hill, 2000
    //  Example 10.1 on page 233
    //  A Ratio class
    
    #include <iostream>
    using namespace std;
    
    class Ratio
    { public:
        void assign(int, int);
        double convert();
        void invert();
        void print();
      private:
        int num, den;
    };
    
    int main()
    { Ratio x;
      x.assign(22,7);
      cout << "x = ";
      x.print();
      cout << " = " << x.convert() << endl;
      x.invert();
      cout << "1/x = ";  x.print();
      cout << endl;
    }
    
    void Ratio::assign(int numerator, int denominator)
    { num = numerator;
      den = denominator;
    }
    
    double Ratio::convert()
    { return double(num)/den;
    }
    
    void Ratio::invert()
    { int temp = num;
      num = den;
      den = temp;
    }
    
    void Ratio::print()
    { cout << num << '/' << den;
    }
    I deeply appreciate any help from you.

  9. #9
    Registered User
    Join Date
    Oct 2011
    Posts
    10
    At the end of the main function before return 0; type system("pause");

  10. #10
    Registered User
    Join Date
    May 2010
    Posts
    73
    Thanks . Now, it is okey.

  11. #11
    Registered User
    Join Date
    May 2010
    Posts
    73
    Last thing, anyone able to help me why I can be able to run the program from command window ? I got no output there.

  12. #12
    Registered User
    Join Date
    May 2010
    Posts
    73
    I got the same in cmd :

    C:\Documents and Settings\C A Arefe>D:

    D:\>cd D:\Book's\Schaum's Programming with C++\Source code\Chapter 8_Classes

    D:\Book's\Schaum's Programming with C++\Source code\Chapter 8_Classes>g++ Ex1001
    .cpp -o Ex1001.exe

    D:\Book's\Schaum's Programming with C++\Source code\Chapter 8_Classes>

    I already installed visual C++ express 2010

  13. #13
    Registered User slartie's Avatar
    Join Date
    Oct 2011
    Location
    Denmark
    Posts
    6
    After compiling, type Ex1001.exe and prepare to be amazed at how far technology has come.

  14. #14
    Registered User
    Join Date
    May 2010
    Posts
    73
    I truly realized just now. Thanks

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21