The following source code is the miniaturization of a major problem that I am working on, and I have not been able to solve the problem for two days.
I need to print the values of the vector generated by the "makeVector" function, in the "main" function.
But for the code to resemble the actual problem I'm working on, there are two restrictions that must be met. These are discussed in the following code.
#include <stdio.h>
#include <stdlib.h>
#define TAM 3
int fazVetor(int **vet){
int *array = malloc(sizeof(int) * TAM);
array[0] = 4;
array[1] = 7;
array[2] = 8;
/* nesta função somente a linha a seguir PODE ser alterada. */
*vet = array;
}
int main()
{
int **qq;
/* Na função main, somente a linha a seguir NÃO PODE ser alterada. */
fazVetor(&qq);
printf("\n--==[Valores do Vetor]==--\n\n");
for(int i = 0; i < TAM; i++){
printf(" %d", (qq[i]));
}
printf("\n\n");
return 0;
}
The above code works, but not the way it should. That is, I can not print the three vector values. At most, I can print out memory addresses.
If anyone can help, it will be of great value!