As those of you who read spam or visit Shue's IRC may already know, I really really really suck at programming.
So someone from the physics department who found out I suck at programming helped me find a good book on how to program.
I'm only on the second chapter and I'm already stuck. I'm using microsoft visual c++ 2008 express edition. I'm taking a program straight from the book with no modifications at all whatsoever and I'm getting errors.
This is a direct copy/paste from the electronic version of this book. When I compile, I getCode:1 // Fig. 2.1: fig02_01.cpp 2 // Text-printing program. 3 #include <iostream> // allows program to output data to the screen 4 5 // function main begins program execution 6 int main() 7 { 8 std::cout << "Welcome to C++!\n"; // display message 9 10 return 0; // indicate that program ended successfully 11 12 } // end function main
Four errors. I figured that somehow the numbering was causing them so I changed it toPractice.cpp
c:\documents and settings\lawrenzo\my documents\visual studio 2008\projects\practice\practice\practice.cpp(1) : error C2059: syntax error : 'constant'
c:\documents and settings\lawrenzo\my documents\visual studio 2008\projects\practice\practice\practice.cpp(3) : error C2014: preprocessor command must start as first nonwhite space
c:\documents and settings\lawrenzo\my documents\visual studio 2008\projects\practice\practice\practice.cpp(7) : error C2143: syntax error : missing ';' before '{'
c:\documents and settings\lawrenzo\my documents\visual studio 2008\projects\practice\practice\practice.cpp(7) : error C2447: '{' : missing function header (old-style formal list?)
Build log was saved at "file://c:\Documents and Settings\Lawrenzo\My Documents\Visual Studio 2008\Projects\Practice\Practice\Debug\BuildLog.htm "
Practice - 4 error(s), 0 warning(s)
and I getCode:// Fig. 2.1: fig02_01.cpp // Text-printing program. #include <iostream> // allows program to output data to the screen // function main begins program execution int main() { std::cout << "Welcome to C++!\n"; // display message return 0; // indicate that program ended successfully } // end function main
So it would seem that it was successful, but I'm not getting any output at all. It doesn't say "Welcome to C++!" anywhere. If I go to compile instead of build, I get the exact same thing. This problem is probably due to the fact that I have no clue how to use microsoft visual c++ 2008 express. Can anyone either explain to me what I'm doing wrong/how to do it right or tell me about another free C++ compiler that would be easier for a beginner to understand?Practice - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
XI Wiki


