Hey, I'm using SAMS teach yourself C++ in 21 days, and currently I am on Day 2, however, I've gotten a lot of errors whenever I compile even though I type out the examples exactly as they should be.

I'm using Borland C++ Compiler. command line tools or something like that.

Heres the example:

#include <iostream>
int main()
{
	std::cout << "Hello there.\n";
	std::cout << "Here is 5: " << 5 << "\n"
	std::cout << "The manipulator std::endl";
	std::cout << "writes a new line to the screen.";
	std::cout << std::endl;
	std::cout << "Here is a very big number:\t << 7000";
	std::cout << std::endl;
	std::cout << "Here is the sum of 8 and 5:\t";
	std::cout << 8+5 << std::endl;
	std::cout << "Here's a fraction: \t\t";
	std::cout << (float) 5/8 << std::endl;
	std::cout << "And a very very big number:\t";
	std::cout << (double) 7000 * 7000 << std::endl;
	std::cout << " Don't forget to replace Jesse Liberty ";
	std::cout << "with your name...\n";
	std::cout << "Jesse Liberty is a C++ programmer!\n";
	return 0;
}

Heres the error:
Error E2379 program.cpp 6: Statement missing ; in function main()
***1 errors in compile***

Line 6 would be std::cout << "The manipulator std::endl";
I cannot for the love of me figure out what is wrong.

Also, can someone suggest a better compiler to use when learning C++ using SAMS?

Help would be really really appreciated.

You forgot the semicolon on "std::cout << "Here is 5: " << 5 << "\n"

It is not necessary to state std::cout on every line -- most programmers code a using statement at the top

#include <iostream>
using std::cout;

int main()
{
	cout << "Hello there.\n";
	cout << "Here is 5: " << 5 << "\n"
	cout << "The manipulator std::endl";
	cout << "writes a new line to the screen.";
	cout << std::endl;
	cout << "Here is a very big number:\t << 7000";
	cout << std::endl;
	cout << "Here is the sum of 8 and 5:\t";
	cout << 8+5 << std::endl;
	cout << "Here's a fraction: \t\t";
	cout << (float) 5/8 << std::endl;
	cout << "And a very very big number:\t";
	cout << (double) 7000 * 7000 << std::endl;
	cout << " Don't forget to replace Jesse Liberty ";
	cout << "with your name...\n";
	cout << "Jesse Liberty is a C++ programmer!\n";
	return 0;
}

Haha Ancient I just learned that now. (Day 2).

Also, thank you Winboy. I really should look over my stuff thoroughly before asking for help.

As for the compiler. You can use DEV'S C++ compiler. That is a good one and it avoids command line compiling.

Alright thanks, I'm downloading it now.

Hey, I am currently teaching myself C++ as well. The book that I would recommend, even more so than the teach yourself C++ in 21 days is another Sams book by Stephen Prata entitled "C++ Primer Plus". This is hands down the best programming book I have ever purchased.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.