Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: [C++] Executable does nothing when running simple iostream program  (Read 10016 times)

0 Members and 1 Guest are viewing this topic.

robin1232



    Rookie

    Re: [C++] Executable does nothing when running simple iostream program
    « Reply #15 on: December 04, 2009, 02:36:36 PM »
    its deprecated, you have to say "using namespace STD"
    like this:

    #include <iostream>
    using namespace std;
    void main()
    {
      cout << "Hello World!"
    }

    you're probably following too old tutorials

    aiko



      Rookie
    • ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆
    • Thanked: 1
      Re: [C++] Executable does nothing when running simple iostream program
      « Reply #16 on: December 18, 2009, 01:50:24 PM »
      if you use vham.exe you can make this automatic.
      1.just write your source
      2.press edit>executable>
      3.write your name of your game/program
      4.save it typ in dos IE00 CHK <name of program>
      5. if your program has no error it is succesfully else the program will fail like a flash

      2x3i5x



        Expert
      • Thanked: 134
      • Computer: Specs
      • Experience: Familiar
      • OS: Windows 10
      Re: [C++] Executable does nothing when running simple iostream program
      « Reply #17 on: December 18, 2009, 02:12:14 PM »
      I think this is what you wanted? Your original code does run after doing the compiling. I compiled with M$ visual C++ 2008 express edition (on Vista 32 bit home edition)

      1.Open start menu
      2. In the search box, type CMD and press Enter when CMD is found
      3. open up the folder where your EXE exists if not already there. Then type in name of program.
      4. I did the above three steps and I see following (and I just saved the file as "jack.exe in a folder named C++")

      NOTE: don't just double click EXE to attempt running it, actually manually open CMD then run it. Else, the program might just exit too quickly for you to see actually the result. This might be why you think program is not working, or you only see a quick flash and then nothing again IF you are sure that you have followed the appropriate steps to compiling your code via your compiler

      Here is screenshot of result:




      Here is code I compiled:
      Code: [Select]
      #include "stdafx.h"
      #include <iostream>
      using namespace std;

      int main()
      {
          char clr[5] = {'o','h','d','s','c'};
          char nmr[10] = {'0','A','J','Q','K','@','#','7','8','9'};
           
          cout << "The Jack of Spades (3;2) is abbreviated: " << clr[3] << "" << nmr[2];
           
             
          cout << "How Awesome...";
         
          cin.get();
          return 0;
      }

      I got rid of int a, because it is an unused variable as is. Don't know what you wanted use a to do. And I find M$ Visual C++ express edition (the free edition of their professional software) to be relatively good to use.  :)
      « Last Edit: December 18, 2009, 02:41:21 PM by 2x3i5x »