Main.c
Every C program has a primary function that must be named main. The main function serves as the starting point for program execution. It usually controls program execution by directing the calls to other functions in the program.
main.c
The main function is declared implicitly by using one of these signatures. You may use any of these signatures when you define your main function. The Microsoft compiler also allows main to have a return type of void when no value is returned. The argv and envp parameters to wmain can also be defined as type char**. For more information about the arguments, see Argument description.
Functions within the source program perform one or more specific tasks. The main function can call these functions to perform their respective tasks. When main calls another function, it passes execution control to the function, so that execution begins at the first statement in the function. A function returns control to main when a return statement is executed or when the end of the function is reached.
You can declare any function, including main, to have parameters. The term "parameter" or "formal parameter" refers to the identifier that receives a value passed to a function. See Parameters for information on passing arguments to parameters. When one function calls another, the called function receives values for its parameters from the calling function. These values are called arguments. You can declare formal parameters to main so that it can receive arguments from the command line using the format shown in the function signature.
When you want to pass information to the main function, the parameters are traditionally named argc and argv, although the C compiler doesn't require these names. Traditionally, if a third parameter is passed to main, that parameter is named envp. The types for argc, argv, and envp are defined by the C language. You can also declare argv as char** argv and envp as char** envp. Examples later in this section show how to use these three parameters to access command-line arguments. The following sections explain these parameters.
If your code adheres to the Unicode programming model, you can use the Microsoft-specific wide-character version of main, wmain, as your program's entry point. For more information about this wide-character version of main, see Using wmain.
A program usually stops executing when it returns from or reaches the end of main, although it can terminate at other points in the program for various reasons. For example, you may want to force the termination of your program when some error condition is detected. To do so, you can use the exit function. For more information on exit and an example of usage, see exit.
In this topic, we will discuss the main in C programming language. A main is a predefined keyword or function in C. It is the first function of every C program that is responsible for starting the execution and termination of the program. It is a special function that always starts executing code from the 'main' having 'int' or 'void' as return data type. In other words, a main() function is an entry point of the programming code to start its execution.
A void is a keyword that references an empty data type that has no return value. In other words, the void data type is used when we don't want to return any value to the calling function. Furthermore, it is used with the main() function to return nothing and can be used with user-defined and predefined functions in C programming.
An int is a keyword that references an integer data type. An int data type used with the main() function that indicates the function should return an integer value. When we use an int main() function, it is compulsory to write return 0; statement at the end of the main() function. The return 0; statement represents that the program has been successfully executed, whereas any other statement represents the unsuccessful termination of the program.
We can also use an EXIT_SUCCESS statement, which is the alternative statement of the return 0. If the program is not successfully executed, we can use the EXIT_FAILURE in the absence of the return 1 statement. The definition of the return statement in the standard input-output header file (stdio.h), whereas the EXIT statement is defined in the standard library (stdlib.h) header file.
A main() function can be called using command line arguments. It is a function that contains two parameters, integer (int argc) and character (char *argv) data type. The argc parameter stands for argument count, and argv stands for argument values.
An int main(void) function is similar to the int main() function to return an integer value. But we can pass more than one argument to the int main(), whereas the int main(void) can only be called without any argument.
A void main (void) function is similar to the void main() function that does not return a value. However, the void main() function can accept multiple parameters, but it does not return a value. It is an empty data type, whereas the void main(void) does not take any parameter because it has a predefined main(void) function.
Hi, I\'d like to connect! '},dataType: 'json',success: function(response) window.location = window.location; ,error: function(response) e.html(t); });} else if (v == 1 v == 2 v == 4) (v == 2 && window.confirm('Are you sure you want to unfriend this person?'))) $.telligent.evolution.del(url: $.telligent.evolution.site.getBaseUrl() + 'api.ashx/v2/users/RequestorId/friends/RequesteeId.json',data: RequestorId: accessingUserId, RequesteeId: userId ,dataType: 'json',success: function(response) window.location = window.location; ,error: function(response) e.html(t); ); else e.html(t); });});(function($)$.extend($.fn.evolutionUpDownVoting.defaults,voteDownMessage:'Vote against this idea',voteUpMessage:'Vote for this idea',loginMessage:'Sign in to vote on ideas',noPermissionMessage:'You do not have permission to vote for this idea',notGroupMemberMessage:'Join this group to vote on this idea',deleteMessage:'Remove your vote for this idea',readOnlyMessage: 'Voting on this idea has been disabled',switchToDownVoteMessage: 'Vote against this idea instead of for it',switchToUpVoteMessage: 'Vote for this idea instead of against it',voteDownAgainMessage:'Vote against this idea again',voteUpAgainMessage:'Vote for this idea again',removeDownVoteMesage:'Remove a vote against this idea',removeUpVoteMessage:'Remove a vote for this idea' );(jQuery));(function($) $.telligent.evolution.media.defaults.endpoint = ' __type=Telligent.Evolution.Api.Plugins.Endpoints.FileViewerEndpoint%2C%20Telligent.Evolution.Platform'; (jQuery));(function($) $.telligent.evolution.preview.defaults.endpoint = ' __type=Telligent.Evolution.Api.Plugins.Endpoints.WebPreviewEndpoint%2C%20Telligent.Evolution.Platform'; (jQuery));(function($) $.fn.evolutionComposer.plugins.mentions.defaults.mentionablesEndpoint = ' __type=Telligent.Evolution.Api.Plugins.Endpoints.MentionablesEndpoint%2C%20Telligent.Evolution.Platform'; (jQuery));(function($) $.telligent.evolution.language.defaults.dateEndpoint = ' __type=Telligent.Evolution.Api.Plugins.Endpoints.DateFormattingEndpoint%2C%20Telligent.Evolution.Platform'; (jQuery));(function($) $.fn.evolutionUserFileTextBox.defaults.endpoint = ' __type=Telligent.Evolution.Api.Plugins.Endpoints.UserFileTextBoxEndpoint%2C%20Telligent.Evolution.Platform'; (jQuery));if (window === window.top) jQuery(function(j)var redirected = false;var ensureLoggedIn = function()if (!redirected) var hashData = jQuery.telligent.evolution.url.hashData();if (hashData._cptype)redirected = true;window.location = jQuery.telligent.evolution.url.modify(url:' :443/signin?returnurl=https%3A%2F%2Fcommunity.arm.com%2Fsupport-forums%2Ff%2Fkeil-forum%2F49509%2Fwhere-is-main-c-file-located-in-keil-uvision-5',query: ReturnUrl:window.location+'',hash: '');;jQuery(window).on('hashchange', function()ensureLoggedIn(););ensureLoggedIn());jQuery(function(j)j.telligent.evolution.theme.social.register(dockedSidebars: true ,adaptiveHeaders: true ,adaptiveHeadersMinWidth: 670));Where is main.c file located in Keil uVision 5? - Keil forum - Support forums - Arm Community .header-fragments .layout .header-top-content .layout-region.header background-color: #FFFFFF;.banner.site fieldset ul.field-list li.field-item .field-item-input input background-color: #FFFFFF;.header-fragments .header-top-content .layout-region.header .banner.site .navigation-list ul a,.header-fragments .header-top-content .layout-region.header .banner.site .navigation-list ul a.active,.header-fragments .header-top-content .layout-region.header .banner.site fieldset ul li .field-item-input input,.header-fragments .header-top-content .layout-region.header .banner.site fieldset ul li .field-item-input input.active,.header-fragments .header-top-content .layout-region.header .banner.site fieldset ul.field-list li.field-item .field-item-input:after,.header-fragments .header-top-content .layout-region.header .banner.site fieldset ul.field-list li.field-item .field-item-input input.active,.header-fragments .header-top-content .layout-region.header .content-fragment.navigation-custom .navigation-list[data-direction='horizontal'] a color: #263238;.header-fragments .header-top-content .layout-region.header .banner.site fieldset ul.field-list li.field-item .field-item-input input::placeholder color: #263238;.header-fragments .header-top-content .layout-region.header .banner.site fieldset ul.field-list li.field-item .field-item-input input:-ms-input-placeholder color: #263238;.header-fragments .header-top-content .layout-region.header .banner.site fieldset ul.field-list li.field-item .field-item-input input::-ms-input-placeholder color: #263238;.header-fragments:hover .header-top-content .layout-region.header .banner.site .navigation-list ul a,.header-fragments:hover .header-top-content .layout-region.header .banner.site .navigation-list ul a.active,.header-fragments .header-top-content .layout-region.header .banner.site .navigation-list ul a.active,.header-fragments:hover .header-top-content .layout-region.header .banner.site fieldset ul li .field-item-input input,.header-fragments:hover .header-top-content .layout-region.header .banner.site fieldset ul li .field-item-input input.active,.header-fragments:hover .header-top-content .layout-region.header .banner.site fieldset ul.field-list li.field-item .field-item-input:after,.header-fragments:hover .header-top-content .layout-region.header .banner.site fieldset ul.field-list li.field-item .field-item-input input.active,.header-fragments .header-top-content .layout-region.header .content-fragment.navigation-custom .navigation-list[data-direction='horizontal'] a.subnav-open,.header-fragments .header-top-content .layout-region.header .content-fragment.navigation-custom .navigation-list[data-direction='horizontal'] a.links-expanded,.header-fragments:hover .header-top-content .layout-region.header .content-fragment.navigation-custom .navigation-list[data-direction='horizontal'] a color: #263238;.header-fragments:hover .header-top-content .layout-region.header .banner.site fieldset ul.field-list li.field-item .field-item-input input::placeholder color: #263238;.header-fragments:hover .header-top-content .layout-region.header .banner.site fieldset ul.field-list li.field-item .field-item-input input:-ms-input-placeholder color: #263238;.header-fragments:hover .header-top-content .layout-region.header .banner.site fieldset ul.field-list li.field-item .field-item-input input::-ms-input-placeholder color: #263238;.header-fragments .header-top-content .layout-region.header .content-fragment.navigation-custom .navigation-list[data-direction='horizontal'] a.selected:after background-color: #263238;.single-column .banner.site background-color: #FFFFFF;.single-column .banner.site > .navigation-list.handheld ul a,.single-column .banner.site .container.handheld .user-links ul a color: #263238;.single-column .banner.site > .navigation-list.handheld ul a.active,.single-column .banner.site .container.handheld .user-links ul a.active color: #263238;Arm CommunitySiteSearchUserSiteSearchUserGroupsResearch Collaboration and Enablement
DesignStart
Education Hub
Innovation
Open Source Software and Platforms
ForumsAI and ML forum
Architectures and Processors forum
Arm Development Platforms forum
Arm Development Studio forum
Arm Virtual Hardware forum
Automotive forum
Compilers and Libraries forum
Graphics, Gaming, and VR forum
High Performance Computing (HPC) forum
Infrastructure Solutions forum
Internet of Things (IoT) forum
Keil forum
Morello Forum
Operating Systems forum
SoC Design and Simulation forum
中文社区论区
BlogsAI and ML blog
Announcements
Architectures and Processors blog
Automotive blog
Graphics, Gaming, and VR blog
High Performance Computing (HPC) blog
Infrastructure Solutions blog
Innovation blog
Internet of Things (IoT) blog
Operating Systems blog
Research Articles
SoC Design and Simulation blog
Tools, Software and IDEs blog
中文社区博客
SupportArm Support Services
Documentation
Downloads
Training
Arm Approved program
Arm Design Reviews
Community HelpMoreCancel.single-column.header-fragments,.header-fragments .layout .header-top-content .layout-region.content,.header-fragments .layout .header-top-content.with-adaptable-elements .layout-region.content background: #11809F;.single-column.header-fragments,.header-fragments .layout .header-top-content .layout-region.content,.header-fragments .layout .header-top-content.with-adaptable-elements .layout-region.content border-bottom: 0px;.header-fragments .layout .header-top-content,.header-fragments .layout .header-top-content.scrolled box-shadow: none;/* parent navigation */.banner.context.slim .hierarchy > .parent-navigation a.more:before,.banner.context > .hierarchy > .parent-navigation ul li a,.banner.context > .hierarchy > .parent-navigation ul li a:hover,.banner.context > .hierarchy > .parent-navigation ul li a:before,.scrolled .banner.context > .hierarchy > .parent-navigation a.more:before,.scrolled .banner.context > .hierarchy > .parent-navigation ul li a:before,.banner.context > .hierarchy > .parent-navigation ul li a.more.links-expanded,.banner.context > .hierarchy > .parent-navigation ul li a.more.links-expanded:before,.banner.context > .hierarchy > .parent-navigation ul li a.more:before color: #FFFFFF;/* hierarchy components */.banner.context > .hierarchy > .current-hierarchy > .hierarchy-component,.banner.context > .hierarchy > .current-hierarchy > .hierarchy-component a,.banner.context > .hierarchy > .current-hierarchy > .hierarchy-component:before,.banner.context > .hierarchy > .current-hierarchy > .hierarchy-component a:hover color: #FFFFFF;/* applications */.banner.context > .hierarchy > .current-hierarchy > .applications ul a,.banner.context > .hierarchy > .current-hierarchy > .applications ul a:hover,.banner.context > .hierarchy > .current-hierarchy > .applications ul a.more,.banner.context:not(.home) > .hierarchy > .current-hierarchy > .applications ul a.more,.banner.context:not(.home) > .hierarchy > .current-hierarchy > .applications ul a.more:before,.banner.context.home > .hierarchy > .current-hierarchy > .applications ul a.more:before,.scrolled .banner.context .hierarchy .current-hierarchy > .applications ul a.more,.scrolled .banner.context .hierarchy .current-hierarchy > .applications ul a.more:before,.banner.context.slim:not(.home) > .hierarchy > .current-hierarchy > .applications ul a.more,.banner.context.slim:not(.home) > .hierarchy > .current-hierarchy > .applications ul a.more:before,.scrolled .banner.context:not(.home) > .hierarchy > .current-hierarchy > .applications ul a.more,.scrolled .banner.context:not(.home) > .hierarchy > .current-hierarchy > .applications ul a.more:before border-color: #FFFFFF;color: #FFFFFF;.banner.context.home > .hierarchy > .current-hierarchy > .applications ul a.links-expanded,.banner.context.home > .hierarchy > .current-hierarchy > .applications ul a.links-expanded:before,.banner.context.home > .hierarchy > .current-hierarchy > .applications ul a.more.links-expanded:before,.scrolled .banner.context .hierarchy .current-hierarchy > .applications ul a.more.links-expanded,.scrolled .banner.context .hierarchy .current-hierarchy > .applications ul a.more.links-expanded:before,.banner.context:not(.home) > .hierarchy > .current-hierarchy > .applications ul a.more.links-expanded,.banner.context:not(.home) > .hierarchy > .current-hierarchy > .applications ul a.more.links-expanded:before,.banner.context.slim:not(.home) > .hierarchy > .current-hierarchy > .applications ul a.more.links-expanded,.banner.context.slim:not(.home) > .hierarchy > .current-hierarchy > .applications ul a.more.links-expanded:before,.scrolled .banner.context:not(.home) > .hierarchy > .current-hierarchy > .applications ul a.more.links-expanded,.scrolled .banner.context:not(.home) > .hierarchy > .current-hierarchy > .applications ul a.more.links-expanded:before background-color: #FFFFFF;color: #11809F;border-color: #FFFFFF;/* new */.banner.context > .new ul a,.banner.context .navigation-list.new ul a.links-expanded,.banner.context .navigation-list.new ul a.links-expanded:hover,.banner.context .navigation-list.new ul a.links-expanded:active,.banner.context .navigation-list.new ul a:hover background-color: #FFFFFF;color: #11809F;.single-column .banner.context > .new a,.single-column .banner.context:not(.home) > .new a,.single-column .banner.context.home > .new a color: #FFFFFF;border-color: #FFFFFF;/* inheriting application banner */.banner.application,.banner.application .navigation-list a,.banner.application .name .title a color: #FFFFFF;.banner.application::after background-color: #FFFFFF;/* custom navigation widget */.header-fragments .content-fragment.navigation-custom .navigation-list[data-direction='horizontal'] a,.header-fragments .content-fragment.navigation-custom .navigation-list[data-direction='horizontal'] a:hover color: #FFFFFF;.header-fragments .content-fragment.navigation-custom:after,.header-fragments .content-fragment.navigation-custom .navigation-list[data-direction='horizontal'] a.selected:after background-color: #FFFFFF;.header-fragments:hover .header-top-content .layout-region.content .content-fragment.navigation-custom .navigation-list[data-direction='horizontal'] a color: #FFFFFF;.header-fragments .header-top-content .layout-region.content .content-fragment.navigation-custom .navigation-list[data-direction='horizontal'] a.links-expanded,.header-fragments .header-top-content .layout-region.content .content-fragment.navigation-custom .navigation-list[data-direction='horizontal'] a.subnav-open,.header-fragments:hover .header-top-content .layout-region.content .content-fragment.navigation-custom .navigation-list[data-direction='horizontal'] a.links-expanded,.header-fragments:hover .header-top-content .layout-region.content .content-fragment.navigation-custom .navigation-list[data-direction='horizontal'] a.subnav-open background-color: #FFFFFF;color: #11809F;Support forumsKeil forumWhere is main.c file located in Keil uVision 5?Jump...Cancel<