相关疑难解决方法(0)

在函数中返回数组

我有一个int arr[5]传递给函数的数组fillarr(int arr[]):

int fillarr(int arr[])
{
    for(...);
    return arr;
}
Run Code Online (Sandbox Code Playgroud)
  1. 我该如何返回该数组?
  2. 我将如何使用它,说我返回一个指针我将如何访问它?

c++ arrays pointers return function

190
推荐指数
8
解决办法
73万
查看次数

使用malloc时,从`void*'无效转换为`char*'?

我在第5行的错误中遇到了以下代码的问题:

错误:无效转换void*char*

我正在使用g ++和codeblocks,我试图将此文件编译为cpp文件.有关系吗?

#include <openssl/crypto.h>
int main()
{
    char *foo = malloc(1);
    if (!foo) {
        printf("malloc()");
        exit(1);
    }
    OPENSSL_cleanse(foo, 1);
    printf("cleaned one byte\n");
    OPENSSL_cleanse(foo, 0);
    printf("cleaned zero bytes\n");
}
Run Code Online (Sandbox Code Playgroud)

c++ malloc g++

55
推荐指数
4
解决办法
8万
查看次数

如何从函数返回数组?

如何从方法返回数组,我该如何声明它?

int[] test(void); // ??
Run Code Online (Sandbox Code Playgroud)

c++ arrays method-signature

44
推荐指数
3
解决办法
15万
查看次数

标签 统计

c++ ×3

arrays ×2

function ×1

g++ ×1

malloc ×1

method-signature ×1

pointers ×1

return ×1