Compiling errors.

I use visual c++ 4.  I got a book with it and I am trying to get the first program to compile.  It gives me an error and I don't know where to find what error it is.  It looks like this in the debugging window:  first.obj - error(s) 1, warning(s) 0.  I want to know what is wrong?
this is the code:

#include <iostream.h>

int main()
{
      cout << "Hello World!";
      cout << endl;
      return 0;
}
EtrainAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
That code compiled and ran fine for me.
0
mitchell042997Commented:
Are you compiling it in a project, which is expecting WinMain?  If you check, when you go to "New File", you can choose an option called something like "console mode" where you can program old DOS C++ programs.  Try going there and using the code yo supplied.  (As is, the code you have shown is error-free for DOS C++.)
0
TKIICommented:
Try to set up a project for this. You can use the AppWizard for this. Go to the File menu. There should be something like create new workspace or project or something. When you have your project then create your source code file and add it to the project. try compiling again (or build the project). Your code is ok, it should run.
For this hello world stuff you should use a console app.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

EtrainAuthor Commented:
Even if I use the console mode it still gives me an error.  Is there any way to tell what the error is?
0
LucHoltkampCommented:
You also need to include iomanip.h which defines endl. Add

#include <iomanip.h>

.luc.
0
EtrainAuthor Commented:
even when I add that it does not work.  Sorry...
0
gunnCommented:
I had this type of stupid problem earlier today just wizzing up a sample test code.

Pick File..New...and pick "Console App" from the list you get. Give your project a name. When thats finished, you will have no files in the project. Pick File..New.. and pick C/C++ source file, make sure the checkmark is checked to add this file to the current project and give it a name.

Now, put the code you have above in that new file and save it. Now, just compile the file: is that ok?

Now, "Build" the project.  That should do it.

If you *still* get an error, please select and copy the error you are getting in the window at the bottom of VisualC++ and paste it in here so we can help you better.

Hope that helps.

0
miredoCommented:
The following sequence of actions worked for me:

1) click File, New, Text File
2) Type in your code.
3) click Build, Build
4) Answer 'yes' to "Would you like to create a default project workspace?"
5) Type in a name and save.
6) click Build, Execute <your filename>.exe

The following appears in a DOS box:

Hello, World!
Press any key to continue_

0
EtrainAuthor Commented:
I tried this many times, but it still gives me an error and I don't no where the error is.  Could anyone tell me where to find what the error is?
0
gunnCommented:
Its in the bottom of the MSVC++ window dialog! You'll see the compiler and linker statements. Any errors you get will show up there.
what are they...please post them.
0
EtrainAuthor Commented:
It just tells me that I have an error but doesn't tell me were it is or what it is.  Is there something that I need to turn on so it will show them?  
0
nietodCommented:
Are you looking at the output window?  The output window lists the errors.  It could be covered by the infoviewer or other window.
0
EtrainAuthor Commented:
--------------------Configuration: hello -Win32 Debug------------
hello.exe - 1 error(s), 0 warning(s)

this is what the screen looks like.  Could anyone tell me what is wrong?
0
nietodCommented:
No.  But maybe we can learn something from a different dirrection.  Try to cause an error and see what happens.  Put in a syntax error and see if the compiler reports it or just the "phantom error".

If you are new to C, you can change the "int" returned from maint to be "Int" (capital I) that should cause a problem (and you were hoping to fix one...)
0
nietodCommented:
By the way, you ARE looking at the right place.  Between the lines you posted there SHOULD be one line that lists the error.
0
nietodCommented:
Actually, there should be at least two lines between what you posted.  I may have an idea of what your problem is.

Do you have a workspace (project) open and do you have the source code file in the projects?
0
EtrainAuthor Commented:
Yes the files are in a project.  Even if I try to put in errors it does not catch them only the configuration error.
0
nietodCommented:
That's interesting.  I think that means that it doesn't even start to compile.  It should print a message that says
"compiling XXXXXX" between the two lines you posted.

There must be something wrong with your workspace.  

You could try creating a new workspace and see what happens.

Do you know if you are creating the workspace correctly?  Unfortunatly, I can't imagine what you could be doing wrong.  Did you choose a console application project type?  Can you see the source code file in the workspace window?

If necessary, you could contact Microsoft technical support.  They will almost certainly be able to help you, but it will cost.
0
EtrainAuthor Commented:
Yes everything is alright with the workspace.  I really didn't want to ask Microsoft, but it might be the only thing to do.  Thanks....
0
nietodCommented:
Well I'm pretty sure the problem is occurring BEFORE it starts to compile your source code.  That's why it does not list the source file and does not list the intentional errors in the source.

What does a compiler do before it compiles?  
0
gunnCommented:
Yes, something is wrong before the compile. I think I had an error like that before, but can't remember specifics...

Start a new Project. Pick New... from the FILE menu and pick 'Console App'. Then, just add the .c file you have created to your project...and thats all. Start with a completely new project, and only save the .c file. Actually, why don't use just type it over again? Its small enough. That way you start fresh. See if that makes the error go away.

If not, then I would suggest uninstalling MSVC++ and then reinstalling it again....


0
SvenTCommented:
--------------------Configuration: hello -Win32 Debug------------
hello.exe - 1 error(s), 0 warning(s)

Has nothing scrolled away from your output window? (have you
checked with the scroll bar?) The error may be something like
"Can't find CL.EXE"

Can you compile your file from a command prompt? (CL HELLO.C)
If not, reinstall MSVC++

Hope this helps!
0
TheTomerCommented:
It sounds to me like an MSVC configuration problem:
1) is there enough disk space?
2) did you name the file with a ".cpp" extension and save it?
3) can you compile any other program (maybe in "c") like:
#include <stdio.h>
void main() { printf("hello, world!\n"); }

0
EtrainAuthor Commented:
I will try these once I get back to school.  Right now I am awy from my usual computer and stuck on another slower computer.

Thanks again.
Etrain
0
EtrainAuthor Commented:
Well, when I got back to school, my system wouldn't boot so I had to dump everything and start over.  The program now runs and is working great.  Thanks for the help.
Etrain......
0
gunnCommented:
Now thats what we told ya to do in the beginning....start over!

Glad its fixed.
0
rbrCommented:
try
int main (int argn, char argv[])
{
...
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nietodCommented:
You don't have to specify arguments to main and the problem was that the MSVC was corrupted or installed incorrectly.  The problem is fixed.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.