Results 1 to 19 of 19

Thread: what the heck!? what's up with this?

  1. #1

    Thread Starter
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242

    what the heck!? what's up with this?

    Hey, can anyone tell me what is wrong with this code?


    code:_______________________________
    #include <iostream.h>

    int main()

    {

    cout << "Hello World!\n";

    return 0;

    }
    ____________________________________


    This SHOULD work shouldn't it? Anyways drop me a line right here people and let me know if you have any solutions. Thanks.


    I'm just startin C++,
    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
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Looks fine to me. How doesn't it work?
    Alcohol & calculus don't mix.
    Never drink & derive.

  3. #3

    Thread Starter
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242
    The problem is this line here:

    #include <iostream.h>

    I don't think it's loading the file. Which then makes the program screw up on the"cout" function. I've had this problem once before but I can't remember what I did to fix it.


    !@#$%&,
    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

  4. #4
    denniswrenn
    Guest
    What compiler are you using? You may need to set the include directories yourself.

  5. #5

    Thread Starter
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242
    I'm using Turbo C++ Lite. It came with the book I bought on C++. I'll try reinstalling it and see if that changes anything.

    BTW: How come none of the avatars are showing up? They just show the litle boxes with X's.


    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

  6. #6
    denniswrenn
    Guest
    1) What version(3.0, 4.5?), if it's 4.5(win 3.11 version) check Options->Projects->Directories, and make sure the include directory is set to: c:\tcwin45\include (or something similar), and the lib directory is set to: c:\tcwin45\lib (or something similar).

    2) Use vbforums.com rather than forums.vb-world.net

  7. #7

    Thread Starter
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242
    I got it to work now. Tell me though, does anyone know if unzipping (the compiler came in a *.zip) the compiler to the folder "c:\c++" cause any errors? When I unzipped it again in a different folder, "c:\tclite", the compiler worked just fine.


    Thanks for what help there. was

    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

  8. #8
    denniswrenn
    Guest
    The compiler probably had problems recognising the plus signs... I always use cpp rather than c++ for folder names to avoid difficulties

  9. #9
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Why use vbforums.com?
    Alcohol & calculus don't mix.
    Never drink & derive.

  10. #10
    denniswrenn
    Guest
    When using forums.vb-world.net the avatars and file attachments don't work.

  11. #11

    Thread Starter
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242

    oh

    OK then, I'll just find the right address then to the vb forums. Shouldn't be too hard.
    I see said the blind man as he spat into the wind.

    It all comes back to me now!

    A.D.T.'s VB

  12. #12

    Thread Starter
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242
    Hey, does anyone know where I can find a decent compiler for free?

    BTW: Still haven't found the correct address for the forums.
    I see said the blind man as he spat into the wind.

    It all comes back to me now!

    A.D.T.'s VB

  13. #13
    denniswrenn
    Guest
    it's http://www.vbforums.com


    A pretty good compiler called Dev-C++ can be found at BloodShed.net

  14. #14
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    The Borland free command line tools (BCC version 5.5 I think) are available from www.borland.com - although you have to register for their community first.

    PS: You should always now use <iostream> rather than <iostream.h>
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  15. #15
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    In Standard C++, the header file iostream.h is not defined. A compiler doesn't have to have this header file to be compliant with the standard. Instead, there is iostream, and the namespace std.
    Code:
    // Instead of:
    #include <iostream.h>
    
    // You should use:
    #include <iostream>
    using namespace std;
    
    // The rest of the code is the same:
    int main()
    {
    	cout << "Hello, world!" << endl;
    	return 0;
    }
    Oh, and also, instead of using "\n" it is common to use "endl", since "endl" also flushes the stream and "\n" doesn't.

    There is an online compiler at http://www.comeaucomputing.com/tryitout/ which compiles (but does not link) your code. It's good for checking whether your code complies to the C++ standard. Great for finding all kinds of silly bugs in the VC++ compiler, and there are many

  16. #16
    denniswrenn
    Guest
    Mike: While he's using TC++ Lite, he can't use <iostream> Borland made TC++4.5 non-standard... there's no standard library It's mainly 'cause TC++ is a learning tool, and it's easier to learn w/o having to fool with the standard library(I guess)....

  17. #17
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    So why is it easier if it makes it totally non-compatible, meaning that you end up having to relearn everything when you get a real compiler?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  18. #18
    denniswrenn
    Guest
    I don't know... the "I guess" in parenthesis was said to indicate that that's what I think Borland thought when making the compiler.. *geeeeesh*... Anyway, I do think it's retarded... I had such a hard time learning *** the std namespace was for(I learned a lot of stuff using TC++4.5 in my computer science class)

  19. #19

    Thread Starter
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242
    Hey slow down guys! I don't know what yer talkin about. Let me read the book first before you guys start talking about "***" are std namespaces. Anyways thanks for the link to the vb forums Dennis. Heh, I didn't completely read your post above I was in a hurry last night typing out those posts. Anyways Dennis I don't think I'll stay with TC++ Lite for long because it won't let me make my own *.exe files. I might stick with it through the book or download one of the suggestions above.

    Thanks everyone for the help. I appreciate the quick responses.



    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

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