BRYANH,
I have a suggestion, explanation of error codes, and the source of the error for you.
suggestion
Please don't take this wrong. Experience in learning a few languages has proven to me that the following is true. If you truly want to learn to write code, it will be of great help to you to manually type the code. By manually typing the code you learn the structure and syntax. As time rolls along you will begin to see problems before you attempt to build the program. I have found that writing and debugging my own code, I have become better at spotting problems. Granted, at this early stage of learning you will be merely typing what you see in the book. By actively using your eyes, hands, and mind you are creating the mental building blocks of understanding. After I have a properly running program, I check it against the code provided in the download. This way I see if there is a difference between the two. Oftentimes examination of the two reveals why the downloaded code is better. It is all a stepwise learning process.
explanation of errors
This is one of the ways I find out what error codes mean.
LNK2001 as found in the help files includes the following excerpts
Quote:
unresolved external symbol "symbol"
Code references something (such as a function, variable, or label) that the linker can't find in the libraries and object files.
This error message is followed by fatal error LNK1120. ...
...What the code asks for doesn't exist (the symbol is spelled incorrectly or uses the wrong case, for example).
|
...and for LNK1120
Quote:
number unresolved externals
Error LNK1120 gives you a count ( number) of unresolved externals for this link. The conditions that cause unresolved externals are described with error LNK2001, which precedes this error message (once for each unresolved external).
|
Of special note here is that LNK means a linker error. If you ever see an error like Cxxxx, where xxxx represents a four digit number, it is a compiler error.
source of the error
Let's look at the error you received and how it applies to the explanations above.
Code:
1>------ Build started: Project: Ex1_02, Configuration: Debug Win32 ------
1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1>c:\users\dad\documents\visual studio 2010\Projects\Ex1_02\Debug\Ex1_02.exe : fatal error LNK1120: 1 unresolved externals
Pay special attention to the parts in red. There is one error, and it is _main. Now let's look for that in your code.
It is found here in red in your code:
Code:
// Ex1_02.cpp A simple console program
#include <iostream> // Basic input and output library
int _main()
{
std::cout << "This is a simple program that outputs some text." << std::endl;
std::cout << "You can output more lines of text" << std::endl;
std::cout << "just by repeating the output statement like this." << std::endl;
return 0; // Return to the operating system
}
Now compare this to the code in the book which is
Do you see the difference? It is the underscore (_) between int and main. This is called a syntax error. If you delete the underscore and keep the space between int and main, the program should build and run properly.
C++ is very sensitive to spelling, upper case versus lower case letters, and quite a few other syntax errors. Don't let this get you down. Everyone (including me) has experienced this type of problem. Even expert programmers experience syntax errors.
If memory serves me correctly, I have posts and/or topics about basic troubleshooting steps and how to find error codes. Search my posts to see if you can find them. If you can't, reply back and I'll try to link to them in my reply back to you.
regards,
drpepper