C++ help

General chat area for anything whatsoever

Moderator: Core Staff

Post Reply
BMC
CJ Fan
CJ Fan
Posts: 140
Joined: December 15th, 2007, 4:22 pm
Location: Bucharest, Romania

C++ help

Post by BMC » September 27th, 2008, 10:22 am

Hello! I need some help with this please. I made a program in C++ which has to calculate the sum of 2 numbers. It worked fine. After that, I wanted to make a countdown and at it's end I wanted to make a house, a car and a train appear. And I get 1 error... Here's the program, if you have C++ please test it and help me fix that error!
#include <stdio.h>
#include <time.h>
#include <iostream> // std::cout, std::cin
#include <ostream> // <<, std::endl;
#include <istream> // >>

int main()
{
double a; // Primul numar introdus
double b; // Al doilea numar introdus

std::cout
<< "Acest program afiseaza suma a doua numere introduse de la tastatura, iar la sfarsit un mic bonus." << std::endl;
std::cin.exceptions( std::ios_base::iostate( -1 ) );
//daca scriu o litera sau orice altceva in afara de cifre, da eroare :)

std::cout << "Introduceti numarul A: ";
std::cin >> a;

std::cout << "Introduceti numarul B: ";
std::cin >> b;

std::cout << "Suma este: " << a + b << "." << std::endl;
return 0;
}

void wait ( int seconds )
{
clock_t endwait;
endwait = clock () + seconds * CLOCKS_PER_SEC ;
while (clock() < endwait) {}
}

int main()

{ <- Here's the error...

int n;
printf ("Incepe numaratoarea...\n");
for (n=5; n>0; n--)
{
printf ("%d\n",n);
wait (1);
}
printf ("Bonus time!\n\n");
printf (" *\n");
printf (" * * ******** \n");
printf (" ***** * * \n");
printf (" * * ** *** \n");
printf (" * * * ** ** * \n");
printf (" ***** *** ***** *** \n");
printf (" __ ________ ________ \n");
printf (" T__ --|| | | | | \n");
printf (" |_______|-|________|-|________| \n");
printf (" OOOO OO OO OO OO OO \n");
return 0;
}
"I don't care either way. I'm tired of you assholes thinking I'm gay just because I like squirrels and guys with sunglasses." - Soviet

User avatar
helium
CJ Spammer!
CJ Spammer!
Posts: 718
Joined: December 31st, 2007, 9:04 am
Location: Sweden

Re: C++ help

Post by helium » September 27th, 2008, 1:07 pm

hmm i couldnt fix it :/ try running it in debug, choose the line where the error occurs and try to remove/fix that text... sry for giving useless help =(
Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: C++ help

Post by Drofder2004 » September 27th, 2008, 2:33 pm

You have 2 functions named the same thing? Main and Main?
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Re: C++ help

Post by Nightmare » September 27th, 2008, 10:53 pm

Drofder2004 wrote:You have 2 functions named the same thing? Main and Main?
What he said, that is the major problem I see in your code.
Also, you forgot the ".h" at the end of your last three includes.
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Re: C++ help

Post by waywaaaard » October 2nd, 2008, 2:05 pm

u dont need the .h

double function name conflict -.- <- copy and paste error etc
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Re: C++ help

Post by Nightmare » October 2nd, 2008, 8:16 pm

Lev!athan wrote:u dont need the .h

double function name conflict -.- <- copy and paste error etc
Depends which compiler you use. To be safe though, it is always good to put .h
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Re: C++ help

Post by waywaaaard » October 4th, 2008, 11:59 am

i guess he doesn't use cygwin - rather more visual studio -.-
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest