This code is intended to test my knowledge of accessing the structure of an array. When I executed this code, it gave me an error two many initializations for the parameter. Please help me understand the error and fix this problem. I tried to reuse code that is already resolved by someone. My question is about populating Struct with Param_u param parameters
#include <iostream> #include <stdio.h> #include <string.h> #define ARRAY_COUNT(arr) (sizeof (arr) / sizeof *(arr)) typedef union { struct { // Function parameters int *array; size_t size; }; struct { // Function return value float mean; int Median; }; } Param_u; int main() { int array_1[] = {1, 2, 3, 4, 5}; int ret1, ret2; // Fill the Struct with parameters Param_u param = { .array = array_1, .size = ARRAY_COUNT(array_1), }; return 0; }
source share