: invalid operands of types 'void' and 'int' to binary 'operator/'
时间: 2023-08-02 11:07:06 浏览: 385
这个错误通常表示您正在尝试将 `void` 类型的值与 `int` 类型的值进行除法操作,而除法操作需要两个具有数值类型的操作数。`void` 类型表示没有返回值的函数或表达式,不允许进行算术运算。
要解决这个错误,您需要确保除法操作的两个操作数都是数值类型。如果其中一个操作数是 `void` 类型,您需要找出导致该操作数为 `void` 类型的原因,并进行修正。
相关问题
invalid operands of types ‘float‘ and ‘int‘ to binary ‘operator&
根据提供的引用内容,我们可以看出这是一个C语言的错误信息,其中%和&都是C语言中的二元运算符。%是求余数运算符,而&是按位与运算符。在C语言中,%和&只能用于整型数据,不能用于浮点型数据。因此,当我们将浮点型数据和整型数据一起使用%或&时,就会出现“invalid operands of types ‘float‘ and ‘int‘ to binary ‘operator%’”或“invalid operands of types ‘float‘ and ‘int‘ to binary ‘operator&’”这样的错误信息。
invalid operands of types ‘float‘ and ‘float‘ to binary ‘operator&
根据提供的引用内容,我们可以看出这是一个关于二元运算符“%”使用不当的错误。在C语言中,“%”运算符只能用于整数类型,而不能用于浮点数类型。因此,如果我们试图将两个浮点数相除并使用“%”运算符,就会出现“invalid operands of types ‘float’ and ‘float’ to binary ‘operator%’”的错误。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)