Trying C++

chris00
09-27-2002, 09:15 PM
Hi Guys

I have been reading some tutorial on C++ and have the following code and get the following error. Whats wrong ???

#include <iostream.h>
int main() {
cout << "Hello World!!!\n";
return 0;
} // main


This is the Error

Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
C:\HELLO.c:
Error E2209 C:\HELLO.c 1: Unable to open include file 'stdio.h'
Warning W8065 C:\HELLO.c 6: Call to function 'printf' with no prototype in function main
*** 1 errors in Compile ***

Pleas HELP !!!

usetheforce2
09-27-2002, 09:25 PM
hmmm, this is weird....
Warning W8065 C:\HELLO.c 6: Call to function 'printf' with no prototype in function main
*** 1 errors in Compile ***

you must have another file your compilier is trying to compile that is using "printf" which does use the stdio.h file.

as for your code, its all good!

good luck

chris00
09-27-2002, 09:30 PM
Should I get another compiler ???

Any good free ones ???

usetheforce2
09-27-2002, 09:35 PM
nope, borland is good....

it this "C:\HELLO.c" the only file in your project?

and is #include <iostream.h>
int main() {
cout << "Hello World!!!\n";
return 0;
} // main
this the only code in that file?

regan

chris00
09-27-2002, 09:40 PM
YES, that the only thing. :)

usetheforce2
09-27-2002, 09:49 PM
hmm, peculiar... i don't use borland (although it doesn't sound compiler specific) so i can't offer you any more suggestion other than opening a new project from scratch, and try it again...

ps. is the link in your sig your site, if it is you have a little typo

What to be a Beta Tester Click !What but want....

Regan

noRulez
09-27-2002, 10:17 PM
Hmmm...I use Borland and Visual C++. You have quite a confusing perdicament going on there. I'm not sure why you'd be naming your files with a .c extension instead of a .cpp extension other than that I assume you pulled the file off the net or something. I'd suggest just starting a new project, and pasting that code in there. If it doesn't compile then...I have no idea. But I've had cases where VC++ would compile a file I had closed hours ago, keeping it open in the background hidden somehow. That would drive me nuts!

chris00
09-27-2002, 11:49 PM
Thanks Guy

I don't know why it dosn't work.

Thanks usetheforce2 for pointing out the spelling error I will fix that when I have time and thanks for checking out my website. :)

JDT
09-28-2002, 12:35 AM
I don't use borland so I am unfamiliar with the errors it will give.

Anyways, if this was VC++, it would not compile either since you dont put std in a namespace or put std:: before cout.

Give this a try and see what happens:

#include <iostream>

int main() {
std::cout << "Hello World!!!\n";
return 0;
} // main

chris00
09-28-2002, 12:39 AM
That fixes part of the problem I still get

Unable to open include file 'istream1'

though

JDT
09-28-2002, 12:45 AM
Hmmm, I just noticed that you are using #include <iostream.h>. That will let you use cout without std:: preceding it. My example was with #include <iostream> (no .h) which needs std::cout.


Not sure what your other problem is though, sorry.

Kashif
09-28-2002, 01:33 AM
Dear Use the File Name
Hello.CPP

i think it will be rectify ur problem

noRulez
09-28-2002, 06:21 AM
kashif,

I thought that may have been a problem also, but I tried it out myself, and it should compile with that filename, although I don't know why or how it got named that way. It almost sounds like you're using a C compiler and not a C++ compiler.

shofstetter
09-30-2002, 07:57 PM
// always give your program the .cpp exstention just using the .c
//will cause your compiler to try to compile it as a c file
// and if this is all the code you need instead of using a project
//just compile the file
//i have used many borland compilers includeing tc++1,2,5 and
//the builder
/*
if you would like there is a good free compiler that i like to use called dev c++
but just to get started i would suggest borlands tc++ 3.0 it has a very exstensive help and tons of documentation and while it isn't very new, it is exstremely easy to use and learn with
*/



try this
open up notepad
and type this

#include <iostream.h>

void main(void){
system("cls"); //clear screen

cout << "Hello World";

}//end main


and name it hello.cpp make sure the exstention on it ends up being cpp notepad is funny about things like that
some times it will look like this hello.cpp.txt
inwitch case you will have to manualy rename the file by right clicking on it
open the file in your compiler and and compile ans run it
it should work just fine

chris00
09-30-2002, 08:09 PM
Thanks for telling me dev c++ works great. :)

shofstetter
09-30-2002, 08:13 PM
no problem

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum