Home >Backend Development >C#.Net Tutorial >What determines the return value type of a C language function?

What determines the return value type of a C language function?

尚
Original
2020-03-02 14:36:4527367browse

What determines the return value type of a C language function?

#The type of return value of a C language function is determined by the function type specified when defining the function.

The type of function value should be specified when defining the function. When defining a function, the type specified for the function value should generally be consistent with the expression type in the return statement. If not, the function type shall prevail, that is, the function type determines the type of the return value.

Example:

int fun(int a)
{
    float a=1.5;
    return a;//warning C4244: 'return' : conversion from 'float ' to 'int ', possible loss of data
}

At this time, 1 is actually returned instead of 1.5.

Recommended: "c Language Tutorial"

The above is the detailed content of What determines the return value type of a C language function?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn