First of all, i'll like to said HI! to all the awesome people on this forum... :3 second... i have this problem as usual that doesnt make any sense :3 can u guy help me out pleasez :O... it's probably ginna look so simple to u... lolz
Im using a compliler called dev c++
herer where i get the error :<
#include <stdlib.h>
#include <iostream>
int counter;
using namespace std;
int main()
{
cout << "This is a Counter to Count from One to Ten (1 - 10)" << endl;
do
counter = counter + 1;
cout << counter; // i get the error here *sad face*
First, please use code tags (the <> button to the right when you post or edit a post.) as it makes the code much easier to read, thanks!
Dev C++ is a deprecated compiler, there's a thread somewhere around here about it. I'd suggest getting another, like the free version of VC++ 2010, or Code::Blocks (though you'll have to update some stuff with that one since the GCC compiler that comes with it was recently update to the C++11 standards.)
As far as I can see the only problem is that you are missing an opening brace after the "do". Any loop can only contain one statement. The way you get around this is to make a "block" with open and close braces so you can include more then one statement. You code should look like this:
#include <stdlib.h>
#include <iostream>
int counter;
usingnamespace std;
int main()
{
cout << "This is a Counter to Count from One to Ten (1 - 10)" << endl;
do
{
counter = counter + 1;
cout << counter; // i get the error here *sad face*
} while (counter != 10);
system("PAUSE");
return 0;
}
Edit: Forgot the ";" after the while test expression. *sad face*
Edit 2: Removed the parentheses around the return value in main.
Thankz A Bunch Phil94, verisimilitude, Raezzor !!! lolz... didnt know it was that simple... :)
oooh and Raezzor a given bigger thanks for spending a little extra time to explain it to me... *send virtually hug* :3
Actually, return (0); is valid. You're forcing the compiler to evaluate (0), which is 0, then to return it. The parenthesis are just extra typing, not an error.