visual studio 2010 questionsssssssss

Hi all..it's me =)
Help me please...
This code can be build and run in codeblocks..

But when i went to VS2010, no matter how i try, it is not working.
Can anyone tell me what is wrong with the codes or what is wrong with this vs2010?



#include <iostream>
#include "StdAfx.h"

int main()
{
int x,y,z;

for (x=1; x<=3; x++)
{
for (y=1; y<3; y++)
{


if (y == 2)
break;
for (z=1; z<3; z++)
{
std::cout << x << " " << y;
std::cout << " " << z << std::endl;
}
}
}

return 0;
}



====


Hello.cpp(1): warning C4627: '#include <iostream>': skipped when looking for precompiled header use
Add directive to 'StdAfx.h' or rebuild precompiled header
Hello.cpp(18): error C2039: 'cout' : is not a member of 'std'
Hello.cpp(18): error C2065: 'cout' : undeclared identifier
Hello.cpp(19): error C2039: 'cout' : is not a member of 'std'
Hello.cpp(19): error C2065: 'cout' : undeclared identifier
Hello.cpp(19): error C2039: 'endl' : is not a member of 'std'
Hello.cpp(19): error C2065: 'endl' : undeclared identifier

Build FAILED.

Time Elapsed 00:00:02.03
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
You're starting a new project incorrectly. You mistakenly started a "New Console Project". This is not a good idea because it causes more issues than a "Blank Project".

Start a "Blank Project" (you may have to change which tree you are viewing on the left) and then right click the "Source Files" on the left and click "Add" -> "New Item" and add a .cpp file (you can name it anything).

Then you can start your program in there. Just this code will do:
1
2
3
4
5
6
7
8
9
10
#include <iostream>
using namespace std;

int main()
{
	cout << "Hello, World!" << endl;
	cin.get();

	return 0;
}
If it works then you can put in your program but without the StdAfx thing.

Screenshots: (yours may differ a little)
http://www.LB-Stuff.com/Temp/VC_NewBlankProj.png
http://www.LB-Stuff.com/Temp/VC_NewItem.png
http://www.LB-Stuff.com/Temp/VC_NewItem2.png
http://www.LB-Stuff.com/Temp/HelloWorld.png
Last edited on
Hello L B.
I will try out in few days time. I'm currently super busy with work =)

But one question...just by the code, how do you know that I started on a new console project?
Clever you =)
#include "StdAfx.h"
That's the giveaway right there. ;)
Topic archived. No new replies allowed.