PDA

Click to See Complete Forum and Search --> : complier problems!


drewski
Feb 25th, 2001, 11:38 PM
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:


#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

HarryW
Feb 26th, 2001, 12:01 AM
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:
#include <iostream>

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

substring
Feb 26th, 2001, 08:05 AM
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.

HarryW
Feb 26th, 2001, 11:49 AM
Ohhh yeah. Best to use the whole standard namespace:

#include <iostream>

using namespace std;

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

drewski
Feb 26th, 2001, 04:14 PM
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.