Sunday, July 12, 2009

C++ in visual?

I have been learning simple codes from readoing "Complete idiot's Guide to C++" All my codes work in MiniGW Developers (IDE). I said why not learn to do it in visual 2005 express as well so I put in the code and it does work.Here's my code just simple.


#include %26lt;iostream.h%26gt;





main(){


int a;





for(a = -10; a %26lt; 10;a++){


cout %26lt;%26lt; a %26lt;%26lt; endl;


}





return 0;


}

C++ in visual?
Did you read the error message??? They aren't put there for fun. They're put there to tell you what's wrong.





You generated a default C++ Console App project using Visual Studio. Your project has a precompiled header in it. But your code doesn't have a precompiled header directive. Hence the error.





Remove the precompiled header from your project. Remove all of the other extraneous stuff that you are not using. Turn off creation of the precompiled header.





Remove all references. You aren't using any.


Remove AssemblyInfo.cpp. You aren't using it.


Remove stdafx.cpp


Remove stdafx.h


Remove resource.h


Remove app.rc


Remove app.ico





Now turn off precompiled header creation. Open the properties of your project. Go to C/C++-%26gt;Precompiled headers-%26gt;Create/Use Precompiled headers.


Select "Not using Precompiled headers."





Now you no longer need a precompiled header diretcive, so you won't get the error that you don't have one.
Reply:(L)


yes c++ is visual.
Reply:in visual studio 2005 make sure you are creating a new win32 console application. i would make the code look a lil different as follows:





#include %26lt;iostream%26gt;


using namespace std;





void main(){





int a;





for(a= -10; a %26lt; 10; a++){


cout%26lt;%26lt;a%26lt;%26lt;endl;


}





}


No comments:

Post a Comment