answersLogoWhite

0


Best Answer

In C Programming there is no real difference. The only criteria associated with the main function is that it must have one (and only one) of the following prototypes:

int main (void);

int main (char* argv[], int argc);

The first is used when the program accepts no arguments, while the second is used when it does accept arguments. The argv argument is a null-terminated array of null-terminated strings, where argv[0] is the fully-qualified path to the executable and argv[argc] is the array's null-terminator.

Some implementations allow other prototypes, however these are non-standard and therefore not guaranteed to be portable across all implementations.

In C++ the main function must be declared in the global namespace. All user-defined functions should (ideally) be declared in user-defined namespaces to avoid polluting the global namespace. In C there are no namespaces; all functions are global. Although C++ supports function overloading, this does not apply to the main function; there can be only one global main function.

In C++, when we reach the end of the main function without encountering a return statement, the all-zeroes bit pattern is implicitly returned. The all-zeroes bit pattern is typically used to denote no error, hence it is the default. However, in C, there is no default return value so a return statement is obligatory. The all-ones bit pattern is typically used to explicitly denote that some error occurred. Other bit patterns may be explicitly returned to denote specific types of error, however not all execution environments make use of the return value.

Other than that, the main function is no different to any other user-defined function.

User Avatar

Wiki User

7y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

main() is so special because it starts the execution of program. or we can say that it is entry gate of any programming language

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

main is user defined function, since in this function user writes his own code.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why you say main is a user defined function?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Which data type can store any data?

There is no such data type. However, when we use user-defined data types of our own type, then that type of data can be stored in a variable. So as a term, you may say that user-defined data type can store any data. As the data-type used in any variable will be depending upon us.


User defined data types in c plus plus?

C++ provides the following fundamental types:A Boolean type (bool)Character types (char and wchar_t)Integer types (int, short, long and long long)Floating-point types (float, double and long double)A type, void, used to signify the absence of information.Fundamental types correspond to the basic storage units of the machine. From the fundamental types we can construct other types using declarator operators:Pointer types (such as int*)Array types (such as char[])Reference types (such as double& and char&&)The Boolean, character and integer types are collectively known as the integral types. The integral and floating-point types are collectively known as the arithmetic types.The fundamental types, pointers, arrays and references are collectively known as the built-in types.The integral types can be further modified using the signed or unsigned modifiers. Strictly speaking, both long and short are also type modifiers because a short implies a short int. This is simply an artefact from C programming where int was implied in the absence of an explicit type.Note that aliases (using x = type) and type definitions (typedef) are not types per se, they are simply alternative names for preexisting types. For instance, although wchar_t is a built-in type because it does not require a declaration, in reality it is just an alias for an implementation-defined integral type (typically unsigned short).From these built-in types we can construct other types:Data structures and classes (such as std::vector and std::string)Enumeration types (enum and enum class)Data structures, classes and enumeration types are collectively known as user-defined types.In essence, any type that requires an explicit declaration is a user-defined type. This includes all C++ standard library types such as std::string because we cannot use a std::string object unless we include the header where the type is declared.


Why Cin and Cout cannot be used outside the main function?

You are completely wrong here.Another answer:There is nothing to say you cannot use cin or coutoutside the main() function (for example, you can use them in a function called from main()). However, using them before main() has been called (e.g. in the constructor of a static object) can have disastrous consequences: cin and cout are themselves static objects, and static initialisation order is undefined. Thus you could be calling them before they have been properly constructed.


What does tbuffer mean in c plus plus?

There is no such keyword or data type known as tbuffer in C++. It's most likely an user-defined identifier, possibly a text buffer. But without knowing its actual type or its context it's impossible to say what it means.


What is prototyping in c plus plus?

A prototype in C++, as well as in C, is a declaration of a function and its parameters, including the types of the function and parameters. It does not actually create (define) the code for the function - it only identifies (declares) it to the compiler. It is used to enforce type checking for functions and parameters, and it is used to declare the function for use in other code prior to the function actually being defined, such as in a different compilation unit or library. Headers, for instance, contain mostly prototypes.

Related questions

What can you say about the end behavior of the function f(x)- In (2x) plus 4?

You cannot because the function is not well-defined. There is no equality symbol, the function In(2x) is not defined.


What is the main function of that organization?

to pump blood throughout the body and keep you alive.


What statement causes a function to executed in PHP?

All usable statements in PHP can cause a function to be executed - however, that's not to say that every statement will execute a function. A statement is defined by the programmer, who it is ultimately the one responsible for including a function, more than one function, or no functions.


Why is function main special?

main() is so special because it starts the execution of program. or we can say that it is entry gate of any programming language


Which data type can store any data?

There is no such data type. However, when we use user-defined data types of our own type, then that type of data can be stored in a variable. So as a term, you may say that user-defined data type can store any data. As the data-type used in any variable will be depending upon us.


What is the main function of bees from an agricultural perspective?

An agricultural perspective? I would have to say their main purpose is to spread pollen from flower to flower, however if you are talking about honeybees which are also pollinators, I would say their main purpose is to make honey.


How user friendly are gateway computers?

Gateway computers are comparable to other major brands of computers, in terms of user-friendliness. The main differences between, say, Gateway and Dell or Gateway and HP does not have much effect on user-friendliness. The real user-friendliness comes from the operating system, and most Gateways will have Windows installed.


User defined data types in c plus plus?

C++ provides the following fundamental types:A Boolean type (bool)Character types (char and wchar_t)Integer types (int, short, long and long long)Floating-point types (float, double and long double)A type, void, used to signify the absence of information.Fundamental types correspond to the basic storage units of the machine. From the fundamental types we can construct other types using declarator operators:Pointer types (such as int*)Array types (such as char[])Reference types (such as double& and char&&)The Boolean, character and integer types are collectively known as the integral types. The integral and floating-point types are collectively known as the arithmetic types.The fundamental types, pointers, arrays and references are collectively known as the built-in types.The integral types can be further modified using the signed or unsigned modifiers. Strictly speaking, both long and short are also type modifiers because a short implies a short int. This is simply an artefact from C programming where int was implied in the absence of an explicit type.Note that aliases (using x = type) and type definitions (typedef) are not types per se, they are simply alternative names for preexisting types. For instance, although wchar_t is a built-in type because it does not require a declaration, in reality it is just an alias for an implementation-defined integral type (typically unsigned short).From these built-in types we can construct other types:Data structures and classes (such as std::vector and std::string)Enumeration types (enum and enum class)Data structures, classes and enumeration types are collectively known as user-defined types.In essence, any type that requires an explicit declaration is a user-defined type. This includes all C++ standard library types such as std::string because we cannot use a std::string object unless we include the header where the type is declared.


What if it doesn't say your user id on stardoll?

It should always say your user id- if not then there may be a glitch in stardoll or you need to reload your page.


Why Cin and Cout cannot be used outside the main function?

You are completely wrong here.Another answer:There is nothing to say you cannot use cin or coutoutside the main() function (for example, you can use them in a function called from main()). However, using them before main() has been called (e.g. in the constructor of a static object) can have disastrous consequences: cin and cout are themselves static objects, and static initialisation order is undefined. Thus you could be calling them before they have been properly constructed.


What is the primary function of the nose?

There will be difference of opinion on this issue. Your doctor will say it has got a respiratory function and a beautician will say it is aesthetic in function.


To say money is socially defined means that?

To say that money is socially defined means that: whatever performs the functions of money extremely well is considered to be money.