In Visual Studio 2008 is there a way to not have to include stdafx.h? I remember Marauder saying you could turn it off in the options but I don't know how.
VC++ confuses me, I miss dev-c++ :(
How do I get rid of stdafx.h?
Moderator: Coders of Rage
How do I get rid of stdafx.h?
I'm an altogether bad-natured Cupid.
- short
- ES Beta Backer
- Posts: 548
- Joined: Thu Apr 30, 2009 2:22 am
- Current Project: c++, c
- Favorite Gaming Platforms: SNES, PS2, SNES, SNES, PC NES
- Programming Language of Choice: c, c++
- Location: Oregon, US
Re: How do I get rid of stdafx.h?
Start a new project, and during the setup turn off the precompiled header. Choose "empty project" instead.Pickzell wrote:In Visual Studio 2008 is there a way to not have to include stdafx.h? I remember Marauder saying you could turn it off in the options but I don't know how.
VC++ confuses me, I miss dev-c++
My github repository contains the project I am currently working on,
link: https://github.com/bjadamson
link: https://github.com/bjadamson
Re: How do I get rid of stdafx.h?
Thanks! A simple program like this would work
But, I have another question...
I did this:
And now I'm WTF-ing
Code: Select all
int main()
{
return 0;
}
I did this:
Code: Select all
#include <iostream>
int main()
{
cout << "Hello World!\n";
cin.get();
return 0;
}
I'm an altogether bad-natured Cupid.
- Bludklok
- Chaos Rift Junior
- Posts: 241
- Joined: Tue Apr 14, 2009 1:31 am
- Current Project: EnigmaCore
- Favorite Gaming Platforms: PC, N64, Playstation1, Playstation2
- Programming Language of Choice: C++
- Location: New Jersey
- Contact:
Re: How do I get rid of stdafx.h?
You forgot to include the namespace...
Code: Select all
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world" << endl;
return 0;
}
Re: How do I get rid of stdafx.h?
I've not used Visual Studio with c++ but try adding:
or put std:: infront of the cout / cin
Edit: I was beaten to it :P
Code: Select all
using namespace std;
Code: Select all
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
std::cin.get();
return 0;
}
- captjack
- Chaos Rift Cool Newbie
- Posts: 50
- Joined: Fri Sep 18, 2009 4:23 pm
- Current Project: engine framework
- Favorite Gaming Platforms: PC, XBox 360, PS3
- Programming Language of Choice: C, C++
- Location: Northern Virginia
Re: How do I get rid of stdafx.h?
And yet one other option. Instead of using the entire std namespace, you could:
This would enable use of just cout and endl without the need for std::cout or std::endl. C++ is really flexible with namespaces.
Code: Select all
#include <iostream>
using std::cout;
using std::endl;
int main()
{
int i = 0;
cout << "i = " << i << endl;
return 0;
}
Re: How do I get rid of stdafx.h?
/facepalm
I forgot to do the most basic thing.
Go me.
I forgot to do the most basic thing.
Go me.
I'm an altogether bad-natured Cupid.