PDA

Click to See Complete Forum and Search --> : Why do i get this error on this simple "Hello world" program?


struntz
Oct 21st, 2000, 11:23 AM
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:
#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 :D


Cory

parksie
Oct 21st, 2000, 12:20 PM
C++ is case-sensitive, and you also didn't give main a return type. So...

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! :D

rippin
Oct 24th, 2000, 02:52 PM
If your code is exactly as you typed it, it is wrong.

try:

#include <iostream.h>

int main()
{
cout << "Hello world!";
return 0;
}


You must return some value from the main() function

Oct 24th, 2000, 03:59 PM
you were missing the void (or return type) prior to your sub.