如果用c语言定义了一个矩阵类型Matrix ,如何定义一个新函数返回矩阵类型

如果用c语言定义了一个矩阵类型Matrix ,如何定义一个新函数返回矩阵类型

示例代码如下
有帮助望采纳

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct pastebin
{
    char s[20];
    int a;
    int b;
    int c;
} ps;

ps func(int x)
{
    ps *a = malloc(sizeof(ps));
    a->b = x;
    return *a;
}
int main(int argc, char const *argv[])
{
    /* code */
    ps x = func(3);
    printf("%d", x.b);
    return 0;
}

啥意思?把返回值定义为矩阵类型就好了啊

一般通过指针参数传递,例如两个矩阵相加的函数这么写:
void matrix_add(matrix* out, matrix* a, matrix* b);