This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
c语言中一个子函数可以有两个返回值吗?
不行!return只能有一个!
但是可以通过其他方式达到目的
1、指针
2、数组(跟指针一样)
3、结构体把两个参数包起来。
你可以return一个指针,这样就能读取两个值了。
返回值只能有一个,但是有很多种途径可以变通的实现返回多个值的目的。比如返回指针;比如把想要返回的值的指针作为形参传到子函数中,子函数可以写入指针指向的变量~