Pages

Wednesday, July 13, 2011

The main() Function in C and C++

The main() function is an user-defined function. Normally every C/C++ program should have a main() function because it is the entry point of any C and C++ program. The C and C++ compiler start compiling and executing any C and C++ program from the main() function. The compiler first calls the main() function and then the main() function calls all the functions having in its body one by one. The smallest C program is shown below.

void main()
{
   
}

Compiling Result

 
The above program will generate no error or no warning but will produce no output because there is no function inside the main() function's body for executing. But if you execute the flowing code, you will see an output on the screen. 
 
#include<stdio.h>
#include<conio.h> 

void main()
{
   clrscr();
   printf("Hello! I'm a novice in C and C++ programming.");
   getch();


Compiling Report



Program Output




8 comments:

Anonymous said...

ӏt iѕ nοt my first time tο pay a quick νisit thiѕ sіte, i
am visіting this sitе ԁaillу and get рleasаnt data from hеrе all the timе.
My page ... Loans for Bad Credit

Anonymous said...

Eѵerythіng is very open ωith a reаlly clear description of the issues.
Ιt was really infοrmаtive.

Your website is extremely helρful. Thank уou for sharing!
My web page - loans for bad credit

Anonymous said...

Ӏ do not evеn κnow how Ι ended up herе, but I thought
thiѕ post was good. I do not know who уοu arе but ԁеfіnitely you're going to a famous blogger if you are not already ;) Cheers!
Feel free to visit my web site :: loans for bad credit

Anonymous said...

Attractive ѕeсtion οf сontent.
I just ѕtumbled upon your web sitе and in accеssion capitаl to assert that I get actuаlly enjoyеd accοunt your blog pоsts.
Any ωay I will be subѕcribing tο your feeds and eѵen I achіеvement you access сonsistently
fast.
Stop by my web-site ... loans for bad credit

Anonymous said...

Α motiѵating discussion iѕ worth commеnt.
I dο bеlіeve that you ѕhould wгite morе about this subject,
іt maу not be a taboo matteг but generally folks don't speak about these subjects. To the next! All the best!!

Review my blog post :: payday

Anonymous said...

Opportunities are available for visitors to purchase a subscription anonymously,
thereby protecting their privacy. At on this occasion I was in college and sharing a
town-home with good friend. Someone who's a foot fetish usually likes a specific form of feet or footwear.

My webpage: free xxx

Anonymous said...

Nobody needs to be hurt due to an addiction. However, they genuinely provide one-time membership with all the features and including renewal date.
During an Amateur Video Chat Session, you can expect their Partner to try and
do the moves consorting to their desire resulting in huge pleasure.


Also visit my web page; live sex chat

daisy said...

just what i was searching. thank you for providing this, a good help for me.

www.n8fan.net