There are some problems. The main thing is that your example reads Alor('a',1,10); it doesn’t help you understand what you want to do.
1) The variable grupo
needs to be an array for integers. If you plan to initialize with an integer value, you cannot copy a char.
2) You need to pass the size of the array you want to initialize and not the position. If you want to update only one array position, just use the right command, you don’t need a method.
grupo[posicao] = valor;
For your example, it would be enough:
a[1] = 10;
3) If you want the method to initialize the entire array, you need to change the arguments and the name.
lerValor gives the impression that you want to recover the value of the array.
In this case, a call from initArray(a,1,10) would place the value "10" at position 0 and at position 1 of the array "a".
void initArray(int grupo[], int tam, int valor)
{
for(int i = 0; i < tam; i++)
{
grupo[i] = valor;
printf("[%i]", grupo[i]);
}
}
4) I don’t know what you would be trying to print there with your printf.
In the above group code is not a vector.
– anonimo
but the group variable in one is of the char? type that receives the, then in my logic it would be: a[posica] = value; which in turn would be: a[1]=10;
– H C
If the variable is char then it has space for a single character. Note that char group is different from char group[].
– anonimo
What is the result obtained and what is the expected result?
– enzo
it returns an error: error: subscripted value is neither array nor Pointer nor vector. really informs that it is not an array, matrix and vector, but how to solve this question? fill several vectors using a function, without using if and switch.
– H C