i got some basics right and i made this program in turbo C:
#include <stdio.h>
main()
{
printf("Hi");
}
ok, when i compile this, i get a warning saying the function should return a value...what does this mean??
i got some basics right and i made this program in turbo C:
#include <stdio.h>
main()
{
printf("Hi");
}
ok, when i compile this, i get a warning saying the function should return a value...what does this mean??
It means that main is a function, which returns an int. You should be doing:Code:int main( void ) { printf("Hi"); return 0; }
Quzah.
Hope is the first step on the road to disappointment.
and try using a better compiler not the outdated compiler TURBO C
you could try dev-c++ compiler
ssharish2005
Although in Turbo C v2.01, that program is running OK.
Last edited by Xero; 08-19-2006 at 03:36 AM.
Just because it's "simple code" doesn't mean you should ignore compiler warnings. Prior to C99, you were allowed to leave off the return type for main, you are no longer allowed to do this. In this case, they luck out by having a crappy old compiler. In the future, they may not be so "lucky". Thus, you should begin to develop good practices early.
If you're going to take the lazy way out all the time, don't bother programming. Or at least, don't bother posting here, because I don't want to have to correct all of your crap you vomit up here.
They also luck out here because they're in main, which is the only function for which the language defines what happens when you omit the return statement. Any other non-void function which reaches the end, and doesn't have a return statement, has undefined behavior for what it actually returns.
In short, you may be able to get away with being a pile of crap, but that doesn't mean you're good for anything other than fertilizer. It also doesn't mean anyone will want to be around you.
Quzah.
Hope is the first step on the road to disappointment.
Thanks for that.Originally Posted by quzah
(First post edited to avoid further confusion, and bad programming practices.
credit for quzah for reminding me 'bout that.)