Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What's the difference between void and int?

Shulou Source: shulou.com Published: 2022-06-02 16:16:33 09月17日 Update

This article mainly introduces what is the difference between void and int. It is very detailed and has certain reference value. Friends who are interested must finish reading it.

The difference between void and int: 1. The function defined by void does not return a value, while the function defined by int returns an integer value; 2. The function with void in front of it cannot return any data, and the return statement cannot be used, while for the function with int in front, the return value is an integer, which can be directly used when the function is called.

The difference between void and int when defining a function: whether the function has a return value

Functions defined by void do not return values, while functions defined by int return integer values.

The function with void in front of it cannot return any data, and the return statement cannot be used. This kind of function should implement all the functions that should be implemented in this function. However, it is not impossible to exchange data with the outside world, it is still possible to pass data through referenced parameters, but the return value cannot be accepted directly when called, because there is no return value.

In front of the int function, the return value is an integer, which may be the number of integers as a result, or the running status, the identification of success or failure. When the function is called, you can directly use the return information to achieve some functions.

These are all the contents of this article entitled "what's the difference between void and int". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Functions data information content functions articles statements success values interests parameters but can pass guys partners integers more identification status knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Docker Apple Linux vpn