Folks I think I will throw all my modest C lore away. Look at this code please:
int main( int argc, char ** argv, char ** envp )
{
int aa;
srand(time(NULL));
int Num=rand()%20;
int Vetor[Num];
for (aa=0; aa<Num; aa++)
{
Vetor[aa]=rand()%40;
printf("Vetor [%d] = %d\n",aa,Vetor[aa]);
}
}
I would think that this should throw an error for two reasons - first that I am declaring both Num and Vetor after executing a command (srand), second because I am declaring Vetor based on Num, this should not be possible right? because those array sizes should not be decided at runtime but at compile time right?
I am really surprised that his works and if you guys could point to some references why I can actually use stuff like this would be great. I think I lost some big changes to C in the last years...
oh by the way, this is using gcc