1.

Solve : [C++] Executable does nothing when running simple iostream program?

Answer»

its deprecated, you have to say "using namespace STD"
like this:

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

you're probably following too old tutorialsif 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
5. if your program has no error it is succesfully else the program will fail like a flashI 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.



Discussion

No Comment Found