VC++2012 cannot open include file stdafx.h
Nov 19, 2012 at 2:31pm UTC
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
Nov 19, 2012 at 2:36pm UTC
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()
}
Nov 19, 2012 at 3:28pm UTC
But .
That Book(Ivor Horton's VC++ 2012)
Really mean that Code was true
:<
Nov 19, 2012 at 3:34pm UTC
And ...
Why that code didn't added
That end of the book . show that [AutoPause] on CMD?
Setting wrong?
Nov 19, 2012 at 4:00pm UTC
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.
Nov 20, 2012 at 10:34am UTC
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 :'<
Nov 20, 2012 at 11:10am UTC
Hmm what if you run your program from the Command Prompt?
Nov 20, 2012 at 12:52pm UTC
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 ;)
Nov 20, 2012 at 3:14pm UTC
Or how about setting a breakpoint (assuming you're running a debug build) before the program terminates to see the output?
Nov 22, 2012 at 9:33am UTC
Deeply thx :]
Lodger , Splux
Nov 22, 2012 at 10:45am UTC
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 .
Nov 26, 2012 at 7:10am UTC
To odai
That Output String "Hello World"
:)
Thx
Topic archived. No new replies allowed.