VC++2012 cannot open include file stdafx.h

1
2
3
4
5
6
7
8
#include "stdafx.h"
#include <iostream>

int _tmain(int argc, _TCHAR argv[])
{
std::cout << "HelloWorld\n";
return 0;
}


I Was Edited Precompiled setting
but I still got that message
Please Answer me :] Deeply Thx
stdafx.h is generated automatically.

Create a new project. And be advised, this is not standard C++.

In standard C++, your program would look like:
1
2
3
4
5
6
7
#include <iostream>

int main(int argc, char *argv[])
{
    std::cout << "Hello, World!\n";
//  return 0; // optional for main()
}

But .
That Book(Ivor Horton's VC++ 2012)
Really mean that Code was true

:<
And ...
Why that code didn't added
 
SYSTEM("PAUSE");

That end of the book . show that [AutoPause] on CMD?

Setting wrong?
Really mean that Code was true

If you don't care about your code being buildable on anything other than Windows, it's OK.

system("PAUSE"); is used to pause the console, so you can read the program's output.
It is not needed if the IDE (e.g. VS 2012) is smart enough to pause the program output automatically.
Hello Catfish2

But . when i entered
Code:
1
2
3
4
5
6
7
#include <iostream>

int main(int argc, char *argv[])
{
    std::cout << "Hello, World!\n";
//  return 0; // optional for main()
}

That program didn't automatically pause :<

vc2012 isn't smart :'<
Hmm what if you run your program from the Command Prompt?
1
2
3
4
5
6
7
8
#include <iostream>

int main(int argc, char* argv[])
{
      std::cout << "Hello world\n";
      std::cin.ignore(80, '\n'); // ignore keypress until '\n' (instead of system("Pause");
      return 0;
}


This ought to solve your problem ;)
Or how about setting a breakpoint (assuming you're running a debug build) before the program terminates to see the output?
Deeply thx :]

Lodger , Splux
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream.h>

int main()

{

     cout<<"hello world\n";

     system ("pause");

     return 0;
}


this code is more simplify , use it and tell me what happen .
To odai

That Output String "Hello World"

:)

Thx
Topic archived. No new replies allowed.