Menu

program runs so quickly I can't even see it

2004-09-23
2012-09-26
  • Nobody/Anonymous

    HEllo there!
    I'm a total newbie to C++ programing. After taking the very first lesson (creating the famous "hello world!" message on the screen), the executable runs so fast that I can't even see the command line window before it dissappears. I've already read the FAQ No.2 that says:
    "2. When executing my dos program, it closes automatically. How I can change this ?

    You can use an input function at the end of you source, like the following example :

    include <stdlib.h>

    int main()
    {
    system(PAUSE);
    return 0;
    }
    "
    but the result is exactly the same as before?! IS there a sloution to this?
    P.S. I'm using Windows XP Pro

     
    • Nobody/Anonymous

      Hi Wayne!

      I am using Dev-C++ 4.9.9.0 on a Windows XP Pro machine. Here's my code and the content of my compiler log:

      include<iostream>

      include<stdlib.h> //only needed if you are using Dev 4 family

      using namespace std; //where the names are - like cout!

      int main(void)
      {
      cout << "This is what that putz Wayne said to do!\n";
      system("pause"); //keep the window open if running from Dev
      return 0;
      }

      Compiler: Default compiler
      Executing g++.exe...
      g++.exe "E:\Dev-Cpp\Moji prvi pokusaji\Untitled1.cpp" -o "E:\Dev-Cpp\Moji prvi pokusaji\Untitled1.exe" -g3 -nostdlib -I"e:\Dev-Cpp\include\c++\3.3.1" -I"e:\Dev-Cpp\include\c++\3.3.1\mingw32" -I"e:\Dev-Cpp\include\c++\3.3.1\backward" -I"e:\Dev-Cpp\lib\gcc-lib\mingw32\3.3.1\include" -I"e:\Dev-Cpp\include" -L"e:\Dev-Cpp\lib" -lobjc -g3 -nostdlib -s
      e:\Dev-Cpp\Bin..\lib\gcc-lib\mingw32\3.3.1........\mingw32\bin\ld.exe: warning: cannot find entry symbol _mainCRTStartup; defaulting to 00401000
      C:\DOCUME~1\Goran\LOCALS~1\Temp/cc6dbaaa.o(.text+0x45): In function main': E:/Dev-Cpp/Moji prvi pokusaji/Untitled1.cpp:6: undefined reference to_alloca'
      C:\DOCUME~1\Goran\LOCALS~1\Temp/cc6dbaaa.o(.text+0x4a):E:/Dev-Cpp/Moji prvi pokusaji/Untitled1.cpp:6: undefined reference to __main' C:\DOCUME~1\Goran\LOCALS~1\Temp/cc6dbaaa.o(.text+0x59):E:/Dev-Cpp/Moji prvi pokusaji/Untitled1.cpp:7: undefined reference tostd::cout'
      C:\DOCUME~1\Goran\LOCALS~1\Temp/cc6dbaaa.o(.text+0x5e):E:/Dev-Cpp/Moji prvi pokusaji/Untitled1.cpp:7: undefined reference to std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp; std::operator&lt;&lt; &lt;std::char_traits&lt;char&gt; &gt;(std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;, char const*)' C:\DOCUME~1\Goran\LOCALS~1\Temp/cc6dbaaa.o(.text+0x6a):E:/Dev-Cpp/Moji prvi pokusaji/Untitled1.cpp:8: undefined reference tosystem'
      C:\DOCUME~1\Goran\LOCALS~1\Temp/cc6dbaaa.o(.text+0x93): In function Z41__static_initialization_and_destruction_0ii': e:/Dev-Cpp/include/c++/3.3.1/iostream:77: undefined reference tostd::ios_base::Init::Init()'
      C:\DOCUME~1\Goran\LOCALS~1\Temp/cc6dbaaa.o(.text+0xae):e:/Dev-Cpp/include/c++/3.3.1/iostream:77: undefined reference to `std::ios_base::Init::~Init()'

      Execution terminated

      Please help!!!

       
    • Jim W.

      Jim W. - 2004-09-23

      Try this: Tools > Compiler > Settings. From there, set everything to No (blank for machine/processor settings).

      It is best not to play with those settings unless/until you know what they are supposed to do....

      -- Jim.

       
    • Nobody/Anonymous

      Thanks, Jim!

      It's working properly now, although I must admit that I still don't know why!

      Goran

       
    • Jim W.

      Jim W. - 2004-09-23

      Probably not something you need to worry too much about at this point, but there should be a section on Compiler Options in Dev's Help. You can see for yourself how changes show up in the compile log....

      -- Jim.

       
    • Wayne Keen

      Wayne Keen - 2004-09-23

      Why it does not work might be the following compile option:

      -nostdlib

      Which explicitly turns off the C++ standard library stuff, which you are using.

      Wayne

       
    • Wayne Keen

      Wayne Keen - 2004-09-23

      I does appear that this thread was hijacked, I don't think the question that was answered was the one originally posted.

      Wayne

       
    • Wayne Keen

      Wayne Keen - 2004-09-23

      Post your full compile log, I suspect you are compiling a windows executable rather than a console one.

      Wayne

       
    • Jim W.

      Jim W. - 2004-09-23

      In case there could be be any confusion, make that:

      Tools > Compiler Options > Settings

      -- Jim.

       

Log in to post a comment.

MongoDB Logo MongoDB