Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts

    C++, hello world?

    PHP Code:
    #include <iostream>

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

    What's the problem with this code? It's driving me insane I try to compile it and I get the following error

    c:/cpp/hello.cpp:7:2: Warning: no newline at end of file
    Line 7 char 2 I guess that is, line 7 is the }

  • #2
    New Coder
    Join Date
    Jun 2002
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts
    For some reason you need a newline at the end of file to compile. Not an error, just a warning. Compilers are picky. Just press enter after the closing brace.

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    That's the most stupid thing I've ever known lol Spent ages trying to figure it out too

    ta for that

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Bah, ok it's compiled into an *.exe now, but if I try to run it from dos, it's too big to fit in memory? so when I try to run it by clicking on the *.exe, it shows a popup saying that it's not a valid win32 file Is this just my compiler trying to wind me up and playing silly buggers with me, or is c++ not meant to work on windows?

  • #5
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    nm, fixed it. I needed the windows.h file thingy


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •