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?

Release: 2020-03-02 14:36:45
Original
27364 people have browsed it

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
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template