Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Beginning C++, got stuck immediately! (http://www.go4expert.com/forums/beginning-cpp-stuck-immediately-t3905/)

grandmasterk 17Apr2007 11:41

Beginning C++, got stuck immediately!
 
I'm doing a C++ video tutorial. They tutors are using Visual Studio 2003, I'm using Visual Studio 2005. Compiling the code just below worked fine for them:


Code:

#include <iostream>

main[]
{
        std;;cout << "Hello World!" << std;;endl;
}

When I tried to compile it I get this error:

Code:

end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?

I don't know what any of this stuff means yet but my C++ project is a Win32 Console Application.

shabbir 17Apr2007 13:20

Re: Beginning C++, got stuck immediately!
 
main [] should be main()


Offtopic comment:
Upi had the quote block where as it should be code block.

DaWei 17Apr2007 17:28

Re: Beginning C++, got stuck immediately!
 
Not only should main [] be main (), main should be declared to return an int. C++ does not support main as a void type, nor does it support an implicit type of int. If your compiler does, it is non-compliant in that respect.

Code:

int main ()
{
  ...
}

Furthermore, the correct syntax is std::cout, NOT std;;cout. This may be a great tutorial, but you need a copy of the material that you can SEE and some other tutorial information that you can READ.

All that is not the seat of your current problem, however. You need to go to Project/Properties/Configuration Properties/C C++/Precompiled Headers and select "Not using precompiled headers". Then delete all references to stdafx as well as stdafx.h.

grandmasterk 18Apr2007 07:54

Re: Beginning C++, got stuck immediately!
 
Wow very good help indeed, better then I was hoping for. Before I continue the lessons can you tell me why it worked for them and not me? It's startng to feel like I'm end up getting alot of that from the tutorials and maybe should find something else to learn from. ($100 well spend it seems.)

Code:

#include <iostream>

int main()
{
        std::cout << "Hello World!" << std::endl;
}

after doing your "not using preomciled headers" steps, that code worked as far as Building. Build Soluttion succeeded. However, Build HelloWorld is the samething as clicking run, yes? (HelloWorld is the title of the project). For them it opens up that DOS window and says Hello World and press any key to continue. Nothing happens when I click Build HelloWorld, except some of that stuff in the output box that tells me it was succesful?

Code:

1>------ Build started: Project: HelloWorld, Configuration: Debug Win32 ------
1>Linking...
1>Embedding manifest...
1>Build log was saved at "file://c:\Documents and Settings\Allen\My Documents\Visual Studio 2005\Projects\HelloWorld\HelloWorld\Debug\BuildLog.htm"
1>HelloWorld - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Really appreciate the help, this is the fourth time in the last 5 years I've attempted to start learning C++ and each time I pretty much ran into a wall right at the beginning and was forced to give up.

grandmasterk 18Apr2007 07:58

Re: Beginning C++, got stuck immediately!
 
Apologies, I forgot the code block again.

DaWei 18Apr2007 08:06

Re: Beginning C++, got stuck immediately!
 
Build is not the same thing as run. Build rebuilds the program from scratch. This means:

1. Each source file (you may have more than one) is
a. preprocessed
b. compiled

2. All resulting object files are linked into an executable.

T-T-t-t-t-hat's a-a-a-a-l-l-l-l f-f-f-f-olks. If you want to run it, do so.

You need to do two things: continue your studies; learn your tools. I doubt seriously that you would buy plans for a gazebo and buy a couple K worth of power tools and start in without reading both the plans AND the manuals for the tools. If you would, don't call me to donate extra fingers for you. Don't do it in programming, either. Your tool (the compiler/IDE) has help files. Use them.

grandmasterk 18Apr2007 08:07

Re: Beginning C++, got stuck immediately!
 
by the way, the configuration manager says Configuration is in Debug mode, is that right? I switched it over to Release to see what that would change and then I started getting that same error from the first post again so I brought it back to Debug.

DaWei 18Apr2007 08:17

Re: Beginning C++, got stuck immediately!
 
Like I said, read your help files. They explain debug versus release mode.

Let me say something else: perhaps this is a game to you, like playing Mario II, or something. If it is, have fun. In the real world it is not a game. It produces things which advance the progress of mankind. Perhaps one percent of professionals, even, get this.

This stuff is used to build intravenous infusions pumps. If you **** around, someone dies. Astronauts don't get home. Less importantly, mail doesn't get delivered. I hope you get the picture.

grandmasterk 18Apr2007 08:59

Re: Beginning C++, got stuck immediately!
 
Quote:

I hope you get the picture.
not in the slightest.

shabbir 18Apr2007 09:26

Re: Beginning C++, got stuck immediately!
 
Quote:

Originally Posted by grandmasterk
Apologies, I forgot the code block again.

Edited again. I think we should have a code block in the Quick Reply as well. Dont you think that will help. I am not a JS expert and so lets hope I can do that.


All times are GMT +5.5. The time now is 03:31.