函数的返回类型可以是结构吗?

时间:2013-08-21 01:24:47

标签: c struct return-type

如问题所示,我们可以从函数返回结构吗。

(struct spMat z) fastTranspose(struct spMat x[20])
{
 //did the process to store transpose in z

 return(z);
}

但现在我收到了错误 错误:预期的标识符或'(''''''''''''''''''''''

有谁能告诉我我做错了什么?

提前完成。

1 个答案:

答案 0 :(得分:0)

我想你想这样做:

struct spMat fastTranspose(struct spMat x[20])
{
     //declare a new struct if you need

     ...

     return x; // or the new struct which you declared before
}