Results 1 to 4 of 4

Thread: Why do i get this error on this simple "Hello world" program?

  1. #1

    Thread Starter
    Registered User struntz's Avatar
    Join Date
    Aug 1999
    Location
    Brockway,Pa,USA
    Posts
    199

    Question

    Hello, i'm having some problems trying to make my first program, i'm getting an errot hsi is what i typed in the DOS PROMPT, C:\Borland\Bcc55\Bin>bcc32 \hello.cpp and i saved my file in teh C: directory, and it says Borland C++ 5.5.1 for win32, \hello.cpp:
    Warning W8070 \hello.cpp 5: Function should return a value in function main() and then it says the turbo Incremntal link, Error: unresolved external '_main' referenced from C:\Borland\bcc55\c0x32.obj

    and my code was:
    Code:
    #include <iostream.h>
    Main()
    {
    cout<<"Hello world";
    }

    i don't understand what i did wrong so if u know, please post it!


    Thanks for listening


    Cory

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169

    Exclamation Damn those capital letters...

    C++ is case-sensitive, and you also didn't give main a return type. So...
    Code:
    void main() {
        cout << "Hello World";
    }
    is what you need.

    One small point...keep your code well-spaced, because when you write larger programs, C++ gets unreadable very quickly!
    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

  3. #3
    Member
    Join Date
    Oct 2000
    Posts
    34
    If your code is exactly as you typed it, it is wrong.

    try:
    Code:
    #include <iostream.h>
    
    int main()
    {
      cout << "Hello world!";
      return 0;
    }
    You must return some value from the main() function

  4. #4
    Guest
    you were missing the void (or return type) prior to your sub.

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