Follow us on Twitter!
Ideas are far more powerful than guns.
Thursday, April 24, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 26
Guests Online: 24
Members Online: 2

Registered Members: 82893
Newest Member: mor-amit
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

error in C++ while compiling


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 01-06-05 06:55
I'm trying to learn c++ and as one of the project examples in the book that i'm reading i modified a few things and messed around figuring out how it reacts.. anywho with my code i get an error while compiling. Here's my source.. i should see the error but i've stared at it for 45 minutes and have got it down to 1 error (there were 3). Here's what i got

Code

//Program 1.2
//Aqrhine Da Vinci
//May 31, 2005

#include <iostream.h>

#define TIME1  88.7     // DownHill
#define TIME2 138.05    // Slalom, 1st att.
#define TIME3 185.16    // Slalom, 2nd att.

#define NAME "P.Wiberg, NOR"
#define SE "sec." << endl

void main ()
{

   cout << endl
       << "Program 1.2" << endl
            << "the Olympic Games, Lillehammer, Norway" << endl
       << "ALPINE SKIING - Combined Slalom Women" << endl
       << "21-feb-94" << endl

       << NAME << endl
       << "Downhill"             << TIME1         << SE
       << "slalom, 1st attempt"   << (TIME2 - TIME1)  << SE
       << "slalom, 2nd attempt"   << (TIME3 - TIME2)  << SE;
}





It's simple simple using the #define directive i get it entirely but there's somthing i'm missing i suppose.

Edited by on 01-06-05 06:55
Author

RE: error in C++ while compiling


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 01-06-05 06:59
What is the error?


Author

RE: error in C++ while compiling


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 01-06-05 07:02
Try the below. I changed #include <iostream.h> to #include <iostream>. Also, I added the line using namespace std;

Lemme know if that works.
Code
//Program 1.2
//Aqrhine Da Vinci
//May 31, 2005

#include <iostream>
using namespace std;

#define TIME1 88.7 // DownHill
#define TIME2 138.05 // Slalom, 1st att.
#define TIME3 185.16 // Slalom, 2nd att.

#define NAME "P.Wiberg, NOR"
#define SE "sec." << endl

void main ()
{

cout << endl
<< "Program 1.2" << endl
<< "the Olympic Games, Lillehammer, Norway" << endl
<< "ALPINE SKIING - Combined Slalom Women" << endl
<< "21-feb-94" << endl

<< NAME << endl
<< "Downhill" << TIME1 << SE
<< "slalom, 1st attempt" << (TIME2 - TIME1) << SE
<< "slalom, 2nd attempt" << (TIME3 - TIME2) << SE;
}





Author

RE: error in C++ while compiling


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 01-06-05 07:08
--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
C:\Documents and Settings\Tommy Waddell\Cpp1.cpp(19) : error C2143: syntax error : missing ';' before '<<'
Cpp2.cpp
Error executing cl.exe.

Cpp1.exe - 1 error(s), 0 warning(s)


and the change to <iostream> and the extra line didn't help
Author

RE: error in C++ while compiling


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 01-06-05 07:42
hmm I didn't have that problem. Try putting all the cout stuff onto one line. What compiler are you using?


Author

RE: error in C++ while compiling


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 01-06-05 08:20
microsoft visual c++
Author

RE: error in C++ while compiling


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 01-06-05 08:35
figured it out.. thanks for your help.. i'm not sure what i did but i just tried it a while later (after restart) and it worked.
Author

RE: error in C++ while compiling


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 01-06-05 20:36
What does this error mean?


--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
C:\Documents and Settings\Tommy Waddell\My Documents\c++\Cpp1.cpp(72) : error C2086: 'x' : redefinition
Error executing cl.exe.

Cpp1.exe - 1 error(s), 0 warning(s)



I get it from this section here:

Code

const int Max = +32767;
   const int Min = -(Max+1);
      int x;

   x = Max;
   
   cout << x << endl;

   x = Max + 1;
   cout << x << endl;

   x = Max + 2;
   cout << x << endl;

   x = Min;
   cout << x << endl;

   x = Min - 1;
   cout << x << endl;

   x = Min - 2;
   cout << x << endl;





sorry.. figured it out seems that the problem wasn't that i redefined the variable "x" but that i accidently declared it a variable twice. once earlier in the code then again where i showed it. works smoothly now.. nothin quite like trial and error

Edited by on 01-06-05 20:46