Find the answer to your Linux question:
Results 1 to 3 of 3
ok here is my code: Code: #include <iostream> using namespace std; int main&#40;&#41;; &#123; cout <<"Hello World!\n"; return 0; &#125; then i try to compile with g++ with this command: ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Mar 2005
    Location
    California!
    Posts
    159

    New to c++, about to pull hair out! can't compile simple helloworld!


    ok here is my code:

    Code:
    #include <iostream>
    using namespace std;
    int main&#40;&#41;;
    &#123;
    cout <<"Hello World!\n";
        return 0;
    &#125;
    then i try to compile with g++ with this command:

    Code:
    g++ hello.cpp -o hello
    to which i get an error of:

    Code:
    hello.cpp&#58;5&#58; error&#58; expected unqualified-id before '&#123;' token
    this will not compile with visual studio either, although i get a different error.

    thoughts?
    Registered Linux User # 392752

    \"pr0n\": An anagram of \"porn,\" possibly indicating the use of pornography.

  2. #2
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,885
    remove the semicolon ( ; ) from the end of the main() declaration, and it'll all work...
    Linux user #126863 - see http://linuxcounter.net/

  3. #3
    Linux Newbie
    Join Date
    Mar 2005
    Location
    California!
    Posts
    159
    WOW it was a typo in my book! OMG now i gotta get a new book!

    thanks man
    Registered Linux User # 392752

    \"pr0n\": An anagram of \"porn,\" possibly indicating the use of pornography.

Posting Permissions

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