Results 1 to 12 of 12

Thread: Hello World

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Sydney Australia
    Posts
    804

    Hello World

    This code fails

    Code:
    #include <iostream.h>
    
    int main ()
    {
      cout << "Hello World!";
      return 0;
    }
    Errors are:

    LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
    Debug/fu.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    What am I doing wrongly?

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Your project is a Windows Application. You want a Win32 Console Application. So make a new project
    Harry.

    "From one thing, know ten thousand things."

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Sydney Australia
    Posts
    804
    To create it I just did:

    new project --> win 32 console app

    Then from file view, right clicked to add a new cpp file.

    In the cpp file I added the code then clicked ! to compile it and it bombed.

    Can someone tell me why?

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Sydney Australia
    Posts
    804
    Originally posted by HarryW
    Your project is a Windows Application. You want a Win32 Console Application. So make a new project
    I just tried it again and it worked. I must have chosen something other than console app , thanks for the help.

  5. #5
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Ah, that's good, I was about to be very confused
    Harry.

    "From one thing, know ten thousand things."

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Code:
    #include <iostream.h>
    
    int main() {
        cout << "Hello World!";
        return 0;
    }
    Pity iostream.h is deprecated
    Code:
    #include <iostream>
    
    using std::cout;
    using std::endl;
    
    int main() {
        cout << "Hello World!" << endl;
        return 0;
    }
    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

  7. #7
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Originally posted by parksie
    Code:
    #include <iostream.h>
    
    int main() {
        cout << "Hello World!";
        return 0;
    }
    Pity iostream.h is deprecated
    Code:
    #include <iostream>
    
    using std::cout;
    using std::endl;
    
    int main() {
        cout << "Hello World!" << endl;
        return 0;
    }
    You sometime try to confuse by using...
    Baaaaaaaaah

  8. #8
    Megatron
    Guest
    If you require many of iostream's routine, then you can just include the whole namespace.
    Code:
    using namespace std;

  9. #9
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Baltimore,MD
    Posts
    536

    Talking Iam sure this will work

    /* This program says hello world*/
    #Include<<iostream.h>>
    voidmain(void)
    {
    cout<<"Hello World!";
    }
    Walter Richardson
    Striver2000 Christian Productions
    Iam seventeen but since I started VB in June of 01 GOD has been helping me excell by finding this great forum with a bunch of GREAT PEOPLE!

  10. #10
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    1. iostream, not iostream.h
    2. void main is incorrect. It should be int main. However, the parameters are optional so using void is okay there. You'll need a return statement.
    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

  11. #11
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    It will works that way, but it will be right if you follow parksie's suggestions.

    change

    #Include<<iostream.h>>

    to

    #include <iostream.h>
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  12. #12
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    This is right
    Code:
    #include <iostream>
    using namespace std;
    
    int main(int argc, char* argv[])
    {
    cout<<"Hello World!"<<endl;
    return 0;
    }
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

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