小编Ale*_*nis的帖子

如何正确传递数组作为函数参数?

当我尝试将数组发送到函数时,我得到一个错误.

这是我的minunit测试程序:

#include "minunit.h"
#include "calc.h"
#include <stdio.h>

int tests_run = 0;

 static char * test_Repetitve() {
     mu_assert("error in test_Repetitive, Repetitive != 7", HistogramArray({1,2,3,4,5,6,7})== 7);
     return 0;
 }

 static char * all_tests() {
         mu_run_test(test_Repetitive);
     return 0;
 }

 int main(int argc, char **argv) {
     char *result = all_tests();
     if (result != 0) {
         printf("%s\n", result);
     }
     else {
         printf("ALL TESTS PASSED\n");
     }
     printf("Tests run: %d\n", tests_run);

     return result != 0;
 }
Run Code Online (Sandbox Code Playgroud)

我遇到的问题是

mu_assert("error in test_Repetitive, Repetitive != 7", HistogramArray({1,2,3,4,5,6,7})== 7);
Run Code Online (Sandbox Code Playgroud)

它进入这个功能: …

c arrays function compound-literals function-call

3
推荐指数
1
解决办法
62
查看次数

标签 统计

arrays ×1

c ×1

compound-literals ×1

function ×1

function-call ×1