I'm completely new to programming of any sort, and am halfway through my second day of trying to learn C++ using a beginners guide that Microsoft's Visual C++ 2008 Express Edition linked to.
The code in the guide is the exact code I'm attempting to compile, but I keep getting the same syntax errors.
Code:
/* Project 1-2
This program displays a conversion table of feet to meters
*/
#include <iostream>
using namespace.std
int main()
{
double f; // Holds the length in feet
double m; // Holds the conversion in meters
int counter;
counter = 0; // Line counter is initially set to zero
for(f = 1.0; f <= 100.0; f++) {
m = f / 3.28; // converts to feet
cout << f << " feet is " << m << " meters.\n";
counter++;
// every 10th line print a blank line
if(counter == 10) {
cout << "\n"; // output a blank line
counter = 0; // reset the line counter
}
}
I've tried looking for solutions on the web as well as the forums here, but I just can't seem to find what I'm looking for. I solved an error in a previous program by simply copying my code and pasting it in a new file and then compiling it like normal, but that didn't work for this program. As near as I can tell, I'm using the exact code that's in the guide, so I don't know if maybe the guide had a typo perhaps.
I would really like someone to look at the code and tell me if they see any errors in the way it's typed out...
Using Visual C++ 2008 Express Edition on a Windows Vista (64) computer.
Compiling from the command line using "Visual Studio 2008 Command Prompt"
Thank you so much.... I do feel like a complete idiot for not noticing either of those errors. Been stumped for hours now searching and reading all over the web. I did notice the "return 0:" mistake and tried to re-compile, but that had no effect on the error messages. Then right after editing this post I saw your reply. Thanks again, I really appreciate your help...
Nope, I have recompiled the program after fixing both mistakes (namespace std; and return 0;) and the program executes as advertised. The only error I get is:
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : war
ning C4530: C++ exception handler used, but unwind semantics are not enabled. Sp
ecify /EHsc
But I get that exact same warning no matter what program I try to compile.