Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 05-26-2005, 05:19 PM   #1
Daemon Poster
 
Techy Geek's Avatar
 
Join Date: Feb 2005
Posts: 1,320
Send a message via MSN to Techy Geek
Default compiling Borland

I have been tryin to learn C++, I got a tutorial and tried this code
Code:
// my first program in C++
#include <iostream.h>
int main <>
{
cout << "hello world!"; >>
return 0;
}

NB that was written by my IT teacher (so was the tutorial) and i am pretty sure that its right
anyway, I am trying to compile it and it comes up with this message:
error E2209 hiworld.cpp 2: Unable to open include file "iostream.h"
Error E2141 hiworld.cpp 3: Declaration syntax error
*** 2 errors in Compile ***
what should I do to get the darn thing to compile, is the code wrong (I'd dearly love the tell the IT teacher he got it wrong, that would be great!!!) or is it something else
Another note, I have to put the BCC32.exe file into the folder from which i am compiling, otherwise it doesnt work but I am completely stuck, please help
__________________

__________________
"If I seem to act unkind, its only me and not my mind" I Want To Tell You, The Beatles, Revolver
"When I am king, you will be first against the wall" Paranoid Android, Radiohead, OK Computer
There are two types of people, those who hate Microsoft, and those who work for it...
Possibly a Mac Convert
Techy Geek is offline   Reply With Quote
Old 05-26-2005, 08:07 PM   #2
Daemon Poster
 
Starr's Avatar
 
Join Date: Apr 2005
Posts: 926
Send a message via AIM to Starr Send a message via MSN to Starr
Default Re: compiling Borland

// my first program in C++
#include <iostream.h>
int main <>
{
cout << "hello world!"; >>
return 0;
}


In the first line: #include <iostream.h> Remove the ".h" so it reads: #include <iosteam>

Also replace the <> in: int main<>, with () so it reads: int main().

Then get rid of the >> after "Hello World!"

Last but not least but a "/n" after the "!" but before the quotes like this: cout << "Hello World!/n";

What "/n" does is it moves the cursor down a line so that when Hello World! appears it isn't followed directly with Press any key to continue. Instead "Press any key to continue." would appear below Hello World. It just makes it easier to read. If you dont understand what I mean then run the program first without the "/n" and then run it with it in so that you see what I mean.

You also need to add: using namespace std;
below #include <iostream>

So finished with those adjustments your code should look like this:
Code:
#include <iostream>
using namespace std;
int main()
{
	cout << "Hello World!\n";
	return 0;
}
Happy Programming. If you need help you can post again, PM, email, or IM me.

Also, what compiler are you using?
__________________

__________________
AMD Athlon 64 3200+ Venice Core, MSI K8N Neo-4, 2x 512 Corsair Dual Channel, Nvidia Geforce fx 6600 256MB, 160GB HardDrive

Windows Vista Business Edition

"There are 10 types of people in the world. Those who know binary and those who don't."
Starr is offline   Reply With Quote
Old 05-27-2005, 05:12 PM   #3
Daemon Poster
 
Techy Geek's Avatar
 
Join Date: Feb 2005
Posts: 1,320
Send a message via MSN to Techy Geek
Default Re: compiling Borland

Quote:
Originally Posted by Starr
Also, what compiler are you using?
borland C++, the actual program I link it to in cmd is bcc32, it still doesnt work however, the new problems are:
error E2209 hiworld.cpp 1 : Unable to open include file "iostream"
Error E2282 hiworld.cpp 2 : Namespace name expected
Error E2451 hiworld.cpp 5 : Undefined aymbol "cout" in function main ()
*** 3 Errors in Compile ***

please help, any is welcome
__________________
"If I seem to act unkind, its only me and not my mind" I Want To Tell You, The Beatles, Revolver
"When I am king, you will be first against the wall" Paranoid Android, Radiohead, OK Computer
There are two types of people, those who hate Microsoft, and those who work for it...
Possibly a Mac Convert
Techy Geek is offline   Reply With Quote
Old 06-29-2005, 03:13 PM   #4
Fully Optimized
 
UK31337's Avatar
 
Join Date: Feb 2005
Posts: 2,776
Default

I suggest you forget all about Borland C++ - it's so old, the legends say Julius Caesar learnt programming on it.

Try Dev C++ - it's what I use - it's bang up to date, free, and you can download addons to program virtually anything in it. It's brilliant - there's no need to buy anything more expensive like MS Visual Studio.

Your code should look like this:

Code:
#include <iostream>

int main()
{
std::cout<<"Hello World!\n";
return 0;
}
Or, you can do:

Code:
#include <iostream>

using namespace std;

int main()
{
cout<<"Hello World!\n";
return 0;
}
Hope this helps. Let us know if you have further problems (I'll be out of the loop for about 10 days).
__________________
Master of common sense. If you don't like it, stop reading.
UK31337 is offline   Reply With Quote
Old 06-29-2005, 06:28 PM   #5
Daemon Poster
 
Starr's Avatar
 
Join Date: Apr 2005
Posts: 926
Send a message via AIM to Starr Send a message via MSN to Starr
Default Re: compiling Borland

http://lab.msdn.microsoft.com/expres...c/default.aspx

^^^^^
Get that. It is free. Dev C++ you have to write extra code so you can see the output with this you won't. Just click Build -> Build Solution then Debug -> Start without debugging.

Also get in the habbit of using the second code malbuc posted.

"using namespace std;" will save you a lot of typng when you start doing bigger projects.
__________________
AMD Athlon 64 3200+ Venice Core, MSI K8N Neo-4, 2x 512 Corsair Dual Channel, Nvidia Geforce fx 6600 256MB, 160GB HardDrive

Windows Vista Business Edition

"There are 10 types of people in the world. Those who know binary and those who don't."
Starr is offline   Reply With Quote
Old 08-04-2005, 04:02 AM   #6
Solid State Member
 
MrSmiley's Avatar
 
Join Date: Aug 2005
Posts: 14
Default Re: compiling Borland

Quote:
Originally Posted by Starr
http://lab.msdn.microsoft.com/expres...c/default.aspx

^^^^^
Get that. It is free. Dev C++ you have to write extra code so you can see the output with this you won't. Just click Build -> Build Solution then Debug -> Start without debugging.

Also get in the habbit of using the second code malbuc posted.

"using namespace std;" will save you a lot of typng when you start doing bigger projects.
Yay for digging up old articles, NO I WILL NOT LET SUCH BLASPHEMY LIVE. Visual Studios C++ (Pre 7.1) is not C++, it is more like... "Visual C++ programming" kinda like how "Turbo C++ programming" was. Dev-C++ use standard, (New national standard, which 7.1 uses is the GCC way to compile). You could also use for more efficent coding.

Code:
#include <iostream>
using std::cout;
using std::endl;
int main(void)
{
    cout << "Hello world, mansecks?"<<endl;
    return 0;
}
Instead of using a namespace for everything that is defined in iostream, which causes more bog on your ram... (after setting up a few namespaces, you start to understand why).
__________________

MrSmiley is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 10:13 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0