int main(){
int x=10;
int valor[x];
}
It's the same thing to do
int main(){
int valor[10];
}
Or using define
// #define x ValorPredefinido
#define x 10 /** EXEMPLO, caso saiba que será esse valor **/
int main(){
int valor[x];
}
From the codes below we do not know the amount that will be needed at the start.
int main(){
int x;
printf("Qual o tamanho do vetor?");
scanf("%d", &x); /** caso seja um valor que o usuário terá de colocar**/
int valor[x];
}
Another option is to use dynamic memory.
int main(){
int *valor;
}
Go allocating memory as you need more space.
- What you can not do is
int valor[x]
without having a value, in the examples
above when it reaches this line x
will have a value