Menu

Strange Problem

2006-11-16
2012-09-26
  • Nobody/Anonymous

    For about 3 weeks now, I've been having this problem where my programs will compile, but will not run. If I write code that has improper syntax, it will give me a compiler error. But, after fixing the syntax errors and hitting compile and run, the program will compile and then do nothing. An application file will save to my save file, but they will not run in Dev C++. I can go to the save file and open the applications from there, but I can't find a way to open them in the program. I've got system("pause") commands placed throughout each program, but that seems to do nothing. I'm not even getting a flash of a program.

    I've attempted uninstalling and reinstalling the program several time to no avail.

    Is there some setting in Dev C++ that I need to adjust or something in Windows XP that I need to fix? Any advise you could give me would be wonderful.

     
    • Wayne Keen

      Wayne Keen - 2006-11-16

      If you're instructor has told people that it is OK to save their stuff in paths like that, please inform them that I told them NOT to do so in the future.

      Wayne

       
    • Anonymous

      Anonymous - 2006-11-16

      Typically this occurs when the path to the executable contains spaces. Since you did not post your compile log we cannot tell.

      You will probably find that the separate compile / run buttons work correctly rather than compile & run. But nonetheless spaces should be avoided in project paths - as mentioned in the "<-PLEASE READ BEFORE POSTING A QUESTION" thread (where it also mentions posting teh Compile Log incidentally).

      Clifford

       
    • Wayne Keen

      Wayne Keen - 2006-11-16

      As the "Please Read" thread also mentions, posting your Basic 3 is always essential.

      Wayne

       
    • Nobody/Anonymous

      //Here's your sample code.

      include <iostream>

      include <string>

      using namespace std;

      class rectangle
      {
      private:
      string name;
      float length, width;
      public:
      void getdata();
      float area();
      void state();
      };

      void compare(float, float, rectangle, rectangle);

      int main()
      {
      rectangle A, B;
      float a, b;

      A.getdata();
      B.getdata();
      a = A.area();
      b = B.area();
      
      compare(a,b,A,B);
      
      system(&quot;pause&quot;);
      
      return 0;
      

      }

      void rectangle::getdata()
      {
      cout << "Input the name for the rectangle: ";
      cin >> name;
      cout << "Input the length and then width for rectangle " << name << ": ";
      cin >> length >> width;
      }

      float rectangle::area()
      {
      cout << "The area of rectangle " << name << " is: " << length*width << "." << endl;

            return length*width;
      

      }

      void rectangle::state()
      {
      cout << name;
      }

      void compare(float a1, float a2, rectangle A, rectangle B)
      {
      if (a1 > a2)
      {
      A.state();
      cout << " is the larger rectangle." << endl;
      }
      else if (a2 > a1)
      {
      B.state();
      cout << " is the larger rectangle." << endl;
      }
      else
      cout << "The areas of the two rectangles are equal." << endl;
      }

      Here's the Compile Log.

      Compiler: Default compiler
      Executing g++.exe...
      g++.exe "C:\Documents and Settings---------\My Documents\C++ Programs\Assignment 14.cpp" -o "C:\Documents and Settings---------\My Documents\C++ Programs\Assignment 14.exe" -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
      Execution terminated
      Compilation successful

      I'm running 4.9.9.2.

      I've tried using just run. It does nothing.

       
    • Wayne Keen

      Wayne Keen - 2006-11-16

      Notice you have spaces galore in your path, including the file name for the program itself. This is a horrendously bad idea.

      Wayne

       
    • Wayne Keen

      Wayne Keen - 2006-11-16

      Your code compiles and runs fine here. You can even enter the data as

      3 5 (no return)

      or

      3 (carriage return)
      5

      and it still works, which is actually cool.

      Here is my log:

      Compiler: Default compiler
      Compiler: Default compiler
      Executing g++.exe...
      g++.exe "C:\cstuff\testit3.cpp" -o "C:\cstuff\testit3.exe" -Wall -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
      Execution terminated
      Compilation successful

      Note that I keep my code in

      c:\mycstuff

      Wayne

       
    • Anonymous

      Anonymous - 2006-11-16

      It is weird that after I mentioned spaces in paths that you posted the compile log without noticing the spaces in the paths!

      Never keep your projects in Windows' "special" folders - they are typically sub-folders of "Documents and Settings" which contains spaces. "My Documents" even contains spaces in anycase. The "Desktop" is also under "Documents and Settings" so don't use that either.

      Clifford

       
    • Wayne Keen

      Wayne Keen - 2006-11-16

      And don't put spaces in the program name. That is a real no-no.

      "It is weird that after I mentioned spaces in paths that you posted the compile log without noticing the spaces in the paths!"

      People get in "reactive" mode sometimes, where the react and provide data, but they obviously don't look at it before they do.

      I am far from immune. I did a homework problem in Solid State physics many years ago in which I calculated what is called a "Packing Ratio", the ratio of the volume of stuff that goes into a space to the storage space volume. I cranked out the problem, without looking at the number, and it was greater than one. The instructor nicely asked me to come help him pack his attic using that information. Boy did I feel STUPID, because, well, I WAS!

      :-)

      Wayne

       
    • Nobody/Anonymous

      Why did it work in that file for two months and then suddenly stop working? Everyone I've talked to in my university C++ class saves it in the "Documents and Settings" file and their programs compile and run. Why the sudden change?

       
    • Wayne Keen

      Wayne Keen - 2006-11-16

      "Why did it work in that file for two months and then suddenly stop working? Everyone I've talked to in my university C++ class saves it in the "Documents and Settings" file and their programs compile and run. Why the sudden change?"

      If you do a search through the list, you will see a number of reports like yours, that say things like "It used to work, why doesn't it now?", or the inevitable wise guys who chime in with "That won't fix it, spaces work fine on mine, Wayne, you're just an idiot".

      I wish I knew why it was not deterministic, but to be honest to a fault, I don't. Sometimes it parses, sometimes it does not.

      Rest assured though, spaces will get around to biting one in the butt eventually.

      Now, all of that being said, those of us with a history in the Unix'y world have run into enough cases where something doesn't parse right that we just stay away from spaces almost instinctively, so we don't name something

      "boy that wayne is a stupid jerk.cpp"

      we name it

      "bleep_off_and_die_wayne.cpp"

      Wayne

       
    • Nobody/Anonymous

      Thanks for the help. It worked.

       

Log in to post a comment.