Menu

doe command promt

starcreek
2008-02-28
2012-09-26
  • starcreek

    starcreek - 2008-02-28

    when i compile my program, the window comes up but then goes away. What causes this? im compiling c programms and i would like to see the result.

    the code is very simple:

    int main(void)
    {
    int num;
    printf("the value of %d", num);

    return 0;
    }

    There are no errors so im assuming that it works properly.

    I did create a project under the MS-DOS console app.

     
    • cpns

      cpns - 2008-02-29

      Given your other posts to this forum, I would suggest that you should be learning C++ rather than C.

      > the source code above does not display
      > a command prompt, although the otheres do.

      No! A "command prompt" generally refers to an instance of cmd.exe, (showing the c:\> prompt); the Windows command processor shell. It is not a DOS prompt, DOS is a different and largely obsolete operating system. Your 'console application' code has no relationship to cmd.exe other than it too is a console mode application.

      With respect to your problem, you have been told teh answer and continue to argue about it. The answer to your exact quation, which is incidentally teh most common question asked here is given the thread you were referred to.

      I have come to the conclusion that it is useless answering your questions since you seem not to understand teh answers even when they are spoon fet to you.

      Think about it - when a program ends, Windows closes its window. That is normal operating system behaviour. If you want to wait to read a programs output, you simply have to stop it from terminating before you are ready.

      Alternatively you can run it from the cmd command prompt, where because it runs as a child process it has no window of its own to close.

      Clifford

       
    • Nobody/Anonymous

      Your exact question is dealt with in the thread titled, NOT ACCIDENTALLY,
      "Please Read Before Posting a Question" - you have been here a while, why
      haven't you bothered to read it yet?

      Wayne

       
    • Nobody/Anonymous

      By the way, there is no MS-DOS involved in a console application.

      Wayne

       
    • starcreek

      starcreek - 2008-02-28

      the source code above does not display a command prompt, although the otheres do.

      Now im just practicing this C Programming Language. And i have run into a few problems.

      One of the Exersizes that it wants me to do states that i should:

      Write a program that computes the Volume of a cube. Have the program prompt the user for each 'dimension' ok alright no problemo.

      my code starts with:

      include <stdio.h>

      int main(void)
      {
      int len, width, height;

      printf(&quot;Enter length: &quot;);
      scanf(&quot;%d&quot;, &amp;len);
      
      printf(&quot;Enter width: &quot;);
      scanf(&quot;%d&quot;, &amp;width);
      
      printf(&quot;Enter height: &quot;);
      scanf(&quot;%d&quot;, &amp;height);
      
      printf(&quot;Volume is %d.&quot;, len * width * height);
      
      return 0;
      

      }

      woohoo! the command prompt is displayed! maybe the programs preceding this were a little to short.

      What is confusing me is that i cant figure out how to get it to display the Dimensions and find the result of user input on the imaginary Volume of the cube.

       
    • starcreek

      starcreek - 2008-02-28

      it does display my result but goes away and i'd like it to stay.

       
    • Nobody/Anonymous

      Then Go read the "Please Read Before Posting a Question" thread like you have been told to do. Your answer is in there.

       
    • Nobody/Anonymous

      yeah but if im right it just terminates, and fails to tell me what i have in printf.

       
      • Nobody/Anonymous

        Are you too lazy to go read what you are told? Or just too damn stupid?

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.