Why void main is used in c
What is the difference between int main , void main and int main void? Next question that might pop up is, what is the format of these and how are they different? What is void main? What is int main?
What is int main void? Which amongst the above should be ideally used and which should be avoided int main Vs void main Vs int main void? To summarize kindly note the following points: void main type should be avoided since this type is acceptable only on IDE running on a Windows-based system.
It is also not according to programming standards for C as OS does not know if the program successfully executed or not. Comparing strings in C What is void pointer in C? Thank you for your suggestion.
Murali Krishna answered. Ambika ambi answered. Main is a driver function. Void is a return type of the main function void means not returning any thing. The program execution starts from the function main this means main is a starting point of your program. We use void main to restrict computer to input any value in the program. It is also a keyword. Void main is a predefined function in "c" from where we start a c program And Void is a return type of a function that is meant return nothing.
Actually each and every function returns some value that means as per our requirement we even use like below: Int main char main etc. Rajat Dhande answered. Because of identification of starting of our our program for compiler. Answer Question. In particular, the answers posted by Jonathan Leffler and yours sincerely.
Add a comment. Active Oldest Votes. Improve this answer. PICC32 presumably is freestanding, not hosted. KeithThompson - I've never been too clear on the difference between hosted and freestanding, but both the PIC32 compilers optionally use the full suite of C standard libraries, which I think means they can be both.
That being said the rest of the line goes " Detly is absolutely correct in his assessment that implementation-defined signatures are allowed. It may or may not be a conforming freestanding implementation.
You're absolutely correct that implementation-defined definitions of main are allowed; I never said otherwise. The comments here are mostly incorrect. A hosted implementation does not have to support the two mentioned forms. The standard for hosted systems , which PIC is not, says black on white: "It shall be defined with a return type of int and with no parameters: int main void Show 5 more comments. Community Bot 1 1 1 silver badge. Martin Beckett Martin Beckett Please specify some reasons for the same as it is helpful for others including me — Moons.
What book? There's nothing about a book in the question. Crowder - I'm assuming the OP didn't invent void main himself. There is a popular C reference book by an author I wont name since his name summons up demons from hell which used void main among many other errors — Martin Beckett.
0コメント