Results 1 to 5 of 5

Thread: complier problems!

  1. #1

    Thread Starter
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242
    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

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    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."

  3. #3
    Addicted Member substring's Avatar
    Join Date
    Feb 2001
    Posts
    148

    Smile

    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.

  4. #4
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    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."

  5. #5

    Thread Starter
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242
    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
  •  



Click Here to Expand Forum to Full Width