also remeber don't use void main since u might want to check it's return value if it's return sucess or right also main is a specailized function which alawys start the program at like entry point for example . u should see some tutorials on c before doing anything on it.
Use void to tell the compiler that the function is not expected to return a value. Use int if the function returns a value. By the way its also dependent on the compiler. Some may demand the void like in your case, so use it, that is if the program returns a value.
Is it true that some compilers require void before main ?
No. Any compiler that claims to compile C is required to allow a return value of int from main(). A return of void from main() is an extension that only some compilers allow. These two definitions of main(), and anything equivalent, are the only correct and portable options:
[QUOTE=seo2005;1019063]I am a beginner in c and would like someone tp help me . My question is why I have to write void before main to execute the c program.
#include<stdio.h>
void main()
clrscr();
{
printf("Hello")
}
of course it is a simple program but the void is responsible to return the value.if u dont put void before main() then how should ur program return the desire value.......
but you can also run the program without puting void......
try it.........
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.