Home Common Problem What is the difference between void and int

What is the difference between void and int

Jan 06, 2021 am 09:58 AM
int void

The difference between void and int: 1. Functions defined by void have no return value, while functions defined by int return integer values; 2. Functions preceded by void cannot return any data, and the return statement cannot be used , and the return value of the function preceded by int is an integer, and the return information can be directly used when the function is called.

What is the difference between void and int

#The operating environment of this tutorial: Dell G3 computer, Windows 7 system, C# version.

Recommended: "c Language Tutorial"

When defining a function, the difference between void and int: whether the function has a return value

Function defined by void There is no return value, the function defined by int returns an integer value.

Functions preceded by void cannot return any data, and the return statement cannot be used. This type of function should implement all functions that should be implemented within this function. But it's not that you can't exchange data with the outside. You can still pass data through reference parameters, but you can't directly accept the return value when calling, because there is no return value.

For functions preceded by int, the return value is an integer. It may be a number whose result is an integer, or it may be the running status, success or failure identification. When the function is called, the return information can be directly used to implement some Function.

The above is the detailed content of What is the difference between void and int. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What does void mean in java What does void mean in java Mar 01, 2023 pm 07:19 PM

In Java, void means "empty", that is, "returns nothing". When the method is declared, it means that the method has no return value. ​void corresponds to a wrapper class "java.lang.Void". The Void class is modified with final and is a non-instantiable placeholder class used to save a reference to the Class object that represents the Java keyword void.

Detailed explanation of the method of converting int type to bytes in PHP Detailed explanation of the method of converting int type to bytes in PHP Mar 06, 2024 pm 06:18 PM

Detailed explanation of the method of converting int type to byte in PHP In PHP, we often need to convert the integer type (int) to the byte (Byte) type, such as when dealing with network data transmission, file processing, or encryption algorithms. This article will introduce in detail how to convert the int type to the byte type and provide specific code examples. 1. The relationship between int type and byte In the computer field, the basic data type int represents an integer, while byte (Byte) is a computer storage unit, usually 8-bit binary data

C++ program to convert double type variable to int type C++ program to convert double type variable to int type Aug 25, 2023 pm 08:25 PM

In C++, variables of type int can only hold positive or negative integer values; they cannot hold decimal values. There are float and double values ​​available for this purpose. The double data type was created to store decimals up to seven digits after the decimal point. Conversion of an integer to a double data type can be done automatically by the compiler (called an "implicit" conversion), or it can be explicitly requested by the programmer from the compiler (called an "explicit" conversion). In the following sections, we'll cover various conversion methods. Implicit conversions The compiler performs implicit type conversions automatically. To achieve this, two variables are required - one of floating point type and the other of integer type. When we simply assign a floating point value or variable to an integer variable, the compiler takes care of all the other things

What is the significance of using void type return value in PHP? What is the significance of using void type return value in PHP? Apr 10, 2024 pm 09:21 PM

In PHP, the void type return value means that the function does not return any value, and is usually used for operations such as updating records that do not require a return value. Use the void keyword when declaring a void function; when calling a void function, the result must not be assigned to a variable. Practical case: void type return value can be used to update database records without returning any information.

The function of void keyword in C language The function of void keyword in C language Feb 19, 2024 pm 11:33 PM

void in C is a special keyword used to represent an empty type, which means data without a specific type. In C language, void is usually used in the following three aspects. The function return type is void. In C language, functions can have different return types, such as int, float, char, etc. However, if the function does not return any value, the return type can be set to void. This means that after the function is executed, it does not return a specific value. For example: voidhelloWorld()

What is the value range of int32? What is the value range of int32? Aug 11, 2023 pm 02:53 PM

The value range of int32 is from -2 to the 31st power to 2 to the 31st power minus 1, that is, -2147483648 to 2147483647. int32 is a signed integer type, which means it can represent positive numbers, negative numbers, and zero. It uses 1 bit to represent the sign bit, and the remaining 31 bits are used to represent the numerical value. Since one bit is used to represent the sign bit, the effective number of int32 bits is 31.

How to convert int to string type in go language How to convert int to string type in go language Jun 04, 2021 pm 03:56 PM

Conversion method: 1. Use the Itoa() function, the syntax "strconv.Itoa(num)"; 2. Use the FormatInt() function to convert int type data into the specified base and return it in the form of a string, the syntax "strconv .FormatInt(num,10)".

How to understand and solve 'javascript:void(O)' problems How to understand and solve 'javascript:void(O)' problems Feb 19, 2024 pm 05:35 PM

What does javascript:void(0) mean? What are the solutions to this problem? When we browse the web, sometimes we encounter some links that do not respond after clicking, but are displayed as "javascript:void(0)" in the browser's address bar. This question may confuse some web visitors as they don't know what the error message, which literally looks like JavaScript code, means. So, let's unpack this together