VC++2012 cannot open include file stdafx.h

Ruri Gokou (10)
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
Catfish2 (666)
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()
}

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

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

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

Setting wrong?
Catfish2 (666)
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.
Ruri Gokou (10)
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 :'<
Catfish2 (666)
Hmm what if you run your program from the Command Prompt?
Splux (45)
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 ;)
Lodger (67)
Or how about setting a breakpoint (assuming you're running a debug build) before the program terminates to see the output?
Ruri Gokou (10)
Deeply thx :]

Lodger , Splux
odai (6)
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 .
Ruri Gokou (10)
To odai

That Output String "Hello World"

:)

Thx
Registered users can post here. Sign in or register to post.