|
-
Feb 26th, 2001, 12:38 AM
#1
Thread Starter
Addicted Member
okay this is my first day of learning C++ and i've got this book here "Teach yourself C++ in 24 hours" and I cant get the complier that came with the book to work. here's my code:
Code:
#include <iostream.h> /*this brings an error of not being able to open file */
int main()
{
cout << "Hello World!\n"; /* this brings an error of undifined symbol */
return 0;
}
Does anyone know how to fix this? The book says I may need to find a different file name for #include but i cant find out what. i can find the file in the directory where the complier is but it's not working please help!
drewski
I see said the blind man as he spat into the wind.
It all comes back to me now!
A.D.T.'s VB
-
Feb 26th, 2001, 01:01 AM
#2
Frenzied Member
What compiler is it? The code you posted should work (I think) in Visual C++ (Microsoft's IDE & compiler) but it might not in other compilers. Try this instead:
Code:
#include <iostream>
int main()
{
cout << "Hello World!\n";
return 0;
}
Harry.
"From one thing, know ten thousand things."
-
Feb 26th, 2001, 09:05 AM
#3
Addicted Member
Adding the .h at the end of the library is outdated technique, but the Microsoft compiler likes that (wonder why? heehee). Anyway, in the absence of the .h, you will have to add:
using std::cout; //right after the #include statement
Hope this helps.
substring.
-
Feb 26th, 2001, 12:49 PM
#4
Frenzied Member
Ohhh yeah. Best to use the whole standard namespace:
Code:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!\n";
return 0;
}
Harry.
"From one thing, know ten thousand things."
-
Feb 26th, 2001, 05:14 PM
#5
Thread Starter
Addicted Member
thanks for the help guys but i figured it out. i don't know what the problem was but i reinstalled my complier and it worked just fine after that.
I see said the blind man as he spat into the wind.
It all comes back to me now!
A.D.T.'s VB
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|