2
I created a size vector defined by a constant, and when calling a function that returns me an integer vector, this error is generated:
incompatible types when assigning to type 'int *[]' from type 'int'
The signature of Function is this below. The intention is to assign the return of one vector to another.
#include <stdlib.h>
#include <stdio.h>
#define TAM 50
int main(int argc, char **argv)
{
int *V_VALORES_GERADOS[TAM];
int *VETOR_ORDENADO[TAM];
int *VETOR_VALORES[TAM];
int *V_FREQ_SIMP_ABS[TAM];
float *V_FREQ_SIMP_REL[TAM];
int *V_FREQ_ACUM_ABS[TAM];
float *V_FREQ_SIMP_ACUM[TAM];
V_VALORES_GERADOS = Gerar_Vetor(6); //ERRO AQUI(PRIMEIRA INSTRUÇÃO DA MAIN)
}
int *Gerar_Vetor(int FATOR){
int x;
int * VALORES = (int *) calloc (TAM, sizeof (int));
//Gera os valores e os armazena em um vetor.
for (x = 1;x <= TAM; x++) {
VALORES[x] = rand() % FATOR + 1;
}
if (VALORES == NULL)
return (NULL);
else
return VALORES;
}
With int *V_VALORES_GERADOS[TAM]; you are setting an array of pointers to integers. Is that right? Wouldn’t it be an array of integers? Or better just a pointer to the beginning of the allocated area?
– user4552