Home > Back-end >  Ask what is the function prototype, thank you
Ask what is the function prototype, thank you

Time:01-16

Test. C the following

Int f (int x);//the line is certainly function prototype function prototype

Int f (int x)//the line is not the function prototype?
{
The return of 100;
}


Now I take the test. The c content changed as follows, that is not the int f (int x); The line

Int f (int x)//the line is not the function prototype?
{
The return of 100;

CodePudding user response:

Int f (int x); This can be declared as

Int f (int x)//this line can be implemented as a
The return of 100;
}

CodePudding user response:

https://zhidao.baidu.com/question/1964441885008271820.html

CodePudding user response:

Function declarations can be omitted parameters, but the first function definition must write the physical parameter name and its corresponding data types,
The main purpose of the function prototype for declaring function return value type and function of expected to accept the number of parameters, the parameter types and parameters of order
If the program without a function in the function prototype (no), appear for the first time build system will use this function (function definition or function calls) constructor prototype
Under the default build system default function return values for int
And parameters to a function type does not make any assumption
Common mistakes
And the function prototype does not match the function call will lead to mistakes in grammar
Function prototypes and function definitions are not consistent, also can produce error
C language environment, if a function declaration is not use, errors may occur, because the default return value as an int type to handle, so it is best to statement function before use



Feel the original poster is lazy, the information on the net or more, why don't you personally to find and to summarize, if you look at the specification of a post also suspect, see 2 May be able to make a comparison, look at multiple time can summarize the more defined,

Finally return true don't bore tip, it's no use.

CodePudding user response:

reference 3 building self-confidence boy reply:
function declarations can be omitted parameters, but the first function definition must write the physical parameter name and its corresponding data types,
The main purpose of the function prototype for declaring function return value type and function of expected to accept the number of parameters, the parameter types and parameters of order
If the program without a function in the function prototype (no), appear for the first time build system will use this function (function definition or function calls) constructor prototype
Under the default build system default function return values for int
And parameters to a function type does not make any assumption
Common mistakes
And the function prototype does not match the function call will lead to mistakes in grammar
Function prototypes and function definitions are not consistent, also can produce error
C language environment, if a function declaration is not use, errors may occur, because the default return value as an int type to handle, so it is best to statement function before use



Feel the original poster is lazy, the information on the net or more, why don't you personally to find and to summarize, if you look at the specification of a post also suspect, see 2 May be able to make a comparison, look at multiple time can summarize the more defined,

Finally return true don't bore tip, it's no use.

Online information is not right, a lot of text logic confusion
Obsess in addition, this does not exist, the concept is to make clear,

CodePudding user response:

Ok, spoil you, premise is that the compiler as streaming from the very beginning and you read the source file,
C meaning under the so-called prototype prototype, what is it?
Used before the function is called to notify compile/connectors, this function has several parameters, each parameter is what kind of, what is and convey the expected return value types,
Why to inform is another problem,

So, whatever the role, in the function is called the line at the top of the function declaration/function definitions can be compiled/connector is understood as the prototype,

Usually we write the statement of purpose is to liberate the location of the function definition,
So, if you can guarantee in the program of a function definition and function calls in the same source file, and define the total in the call above, it is not a function declaration,
So so, in the context of the usual, we call the function declaration in the header file, as well as in the source file located close to the direction of the file header function declaration for the function prototype,

CodePudding user response:

Appear below the call, on the other hand, the function definition in the other documents/can't afford to prototype, so don't think that is a prototype,

CodePudding user response:

Summary, above the call to let the compiler completely blind is not prototype, no matter how perfect your written below,

CodePudding user response:

Oracleperl
reference 4 floor response:
Quote: refer to the third floor confident boy reply:
function declarations can be omitted parameters, but the first function definition must write the physical parameter name and its corresponding data types,
The main purpose of the function prototype for declaring function return value type and function of expected to accept the number of parameters, the parameter types and parameters of order
If the program without a function in the function prototype (no), appear for the first time build system will use this function (function definition or function calls) constructor prototype
Under the default build system default function return values for int
And parameters to a function type does not make any assumption
Common mistakes
And the function prototype does not match the function call will lead to mistakes in grammar
Function prototypes and function definitions are not consistent, also can produce error
C language environment, if a function declaration is not use, errors may occur, because the default return value as an int type to handle, so it is best to statement function before use



Feel the original poster is lazy, the information on the net or more, why don't you personally to find and to summarize, if you look at the specification of a post also suspect, see 2 May be able to make a comparison, look at multiple time can summarize the more defined,

Finally return true don't bore tip, it's no use.

Online information is not right, a lot of text logic confusion
Obsess in addition, this does not exist, the concept is to make clear,


So, you need to decide and summary, from the Internet or find information faster, checked if special documents or books, I think you are not so fast, online statements may be added a lot of people his own opinions on the inside, and might be more easy to understand, explain the more often there will be, for example, a concept, described may not you can understand,

CodePudding user response:

We all know that C language advocated by include the header file before the call to provide the function prototype first, we do,
Anyone who violates this principle, in C ape looks tampering,

So I said I can't provide the function prototype that you need a precise definition, thus unable to answer your question, fifth floor functional description described are flank,
Which is the tangle of I also still think of you,
  • Related