English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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

main(){
int a;

for(a = -10; a < 10;a++){
cout << a << endl;
}

return 0;
}

2006-10-27 17:38:12 · 3 answers · asked by Best Helper 4 in Computers & Internet Programming & Design

The code didn't work in visual but work in the other one (MGW IDE)

2006-10-27 17:47:53 · update #1

1>------ Build started: Project: new, Configuration: Debug Win32 ------
1>Compiling...
1>new.cpp
1>c:\documents and settings\gagandeep\my documents\visual studio 2005\projects\new\new\new.cpp(13) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
1>Build log was saved at "file://c:\Documents and Settings\Gagandeep\My Documents\Visual Studio 2005\Projects\new\new\Debug\BuildLog.htm"
1>new - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

it still didn't work when u change it

2006-10-27 17:50:37 · update #2

3 answers

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++->Precompiled headers->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.

2006-10-28 11:22:53 · answer #1 · answered by Lisa A 7 · 0 0

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
using namespace std;

void main(){

int a;

for(a= -10; a < 10; a++){
cout< }

}

2006-10-28 00:48:18 · answer #2 · answered by Anonymous · 0 0

(L)
yes c++ is visual.

2006-10-28 00:46:30 · answer #3 · answered by Julia R 5 · 0 0

fedest.com, questions and answers