Valhalla Legends Forums Archive | C/C++ Programming | iostream problems, and compile errors for a simple program!

AuthorMessageTime
Tron
I don't know why, but i'm getting several compile errors. I'm using Borland Compiler using CMD Prompt if you must know. And also, it also says it can't find my iostream libraries... Which i've noticed are in most C++ Programs. Any help would be great, and thanks for your time!

[code]/*
This program displays "My First C++ Program... Isn't it great?" to the Standard Output
*/

#include <iostream>

int main ()
{
std::cout << "My First C++ Program... Isn't it great?";
return 0;
}[/code]
February 20, 2004, 8:19 AM
iago
Try #include <iostream.h>
February 20, 2004, 1:05 PM
j0k3r
Yeah, what Iago said, and you don't need "std::" in front of cout.
February 20, 2004, 3:01 PM
DVX
[quote author=iago link=board=30;threadid=5377;start=0#msg45147 date=1077282348]
Try #include <iostream.h>
[/quote]

i wouldn't recomend trying to use iostream.h which avoids using the std namespace... use iostream. if your compiler isn't finding the libraries look at where it's looking for them at?
additionally, borland's compiler sucks.. and their linker is worse

[quote author=j0k3r link=board=30;threadid=5377;start=0#msg45158 date=1077289286]
Yeah, what Iago said, and you don't need "std::" in front of cout.
[/quote]

if you are using iostream.h then you don't have too.. but with iostream you must unless you bring cout to local or global scope where you are calling the cout stream
February 20, 2004, 3:25 PM
Skywing
Are you getting a compile-time or link-time error?

And, yes, you should use <iostream> and std::cout, not <iostream.h> + cout.
February 20, 2004, 7:11 PM
Kp
Also, you should fix your prototype for main (though I doubt that's causing problems in this particular situation).
February 20, 2004, 7:36 PM
Adron
[quote author=Tron link=board=30;threadid=5377;start=0#msg45142 date=1077265141]
I don't know why, but i'm getting several compile errors. I'm using Borland Compiler using CMD Prompt if you must know. And also, it also says it can't find my iostream libraries... Which i've noticed are in most C++ Programs. Any help would be great, and thanks for your time!
[/quote]

Post the exact error you're getting. Perhaps you're just using an out of date Borland Compiler that doesn't have the right standard C++ libraries?
February 20, 2004, 7:38 PM
iago
[quote author=Kp link=board=30;threadid=5377;start=0#msg45184 date=1077305790]
Also, you should fix your prototype for main (though I doubt that's causing problems in this particular situation).
[/quote]

What's wrong with his prototype for main? Isn't int main( void ) acceptable?
February 20, 2004, 8:08 PM
Kp
[quote author=iago link=board=30;threadid=5377;start=0#msg45205 date=1077307733]What's wrong with his prototype for main? Isn't int main( void ) acceptable?[/quote]

That's not what he wrote, and it looks wrong without regard to whether it's standard-compliant! :)
February 20, 2004, 9:42 PM
Tron
Ok, so i'll post the compile errors i'm getting. Also, i'm using "Windows 2000 Professional Edition". Just in case it regards the OS which I doubt. Anyways here are the errors:

[code]Error E2209 First.cpp 5: Unable to open include file 'iostream'

Error E2090 First.cpp 9: Qualifier 'std' is not a class or namespace name in function main()

Error E2379 First.cpp 9: Statement missing ; in function main()[/code]

Borland C++ 5.5.1 (c) 1993, 2000 Borland. And thanks for your help!

Edit: I also have Visual Studio 6.0 compiler, but it's kind of a pain to use because of the workspace you have to create... or maybe i'm just lazy.
February 20, 2004, 10:08 PM
DVX
[quote author=Tron link=board=30;threadid=5377;start=0#msg45235 date=1077314926]
Ok, so i'll post the compile errors i'm getting. Also, i'm using "Windows 2000 Professional Edition". Just in case it regards the OS which I doubt. Anyways here are the errors:

[code]Error E2209 First.cpp 5: Unable to open include file 'iostream'

Error E2090 First.cpp 9: Qualifier 'std' is not a class or namespace name in function main()

Error E2379 First.cpp 9: Statement missing ; in function main()[/code]

Borland C++ 5.5.1 (c) 1993, 2000 Borland. And thanks for your help!

Edit: I also have Visual Studio 6.0 compiler, but it's kind of a pain to use because of the workspace you have to create... or maybe i'm just lazy.
[/quote]

well..based on the compile errors it's not able to locate iostream, or the compiler is failing to open the file and include it in which case your compiler is probably not a good one...additionally i believe your compiler is out of date if it thinks std is not a namespace or class...check borland's website for later updates. also, i wouldn't recomend borland anyways. if you have microsoft's compiler, use it, IMO it's better than borland, though i would have to argue that gcc is better for more general use and linux-specific programming.
February 21, 2004, 12:25 AM
iago
Well, it can't open the file iostream so obviously it's not going to find std::.
February 21, 2004, 1:51 AM
Adron
Searching a bit on the net, it seems that Borland C++ 5.5 is supposed to support iostream. Maybe you haven't created a project and set the paths correctly in your Borland C++ 5.5? You could try creating a project and setting up the include directories.

Since Borland C++ 5.5 seems to be free, I might download it and try your example out, some time, if i have nothing better to do...
February 21, 2004, 10:43 AM
DVX
Don't get Borland C++ Builder X
February 21, 2004, 8:14 PM
Adron
[quote author=DVX link=board=30;threadid=5377;start=0#msg45365 date=1077394487]
Don't get Borland C++ Builder X
[/quote]

Because?
February 21, 2004, 8:21 PM
Eli_1
I use borland also and used to get that error, from now on when your compiling something, include this in the command line

bcc32.exe -I..\include\ -L..\lib\ codesource.cpp

that should fix it ::)
February 22, 2004, 11:07 PM

Search