And*_*uun 1 c arrays random printf format-specifiers
我创建了一个包含随机数的数组,但是当我打印数组时它们都是0,这里有什么问题?我知道随机数在那里,但仍然是零?
int superArray[SIZE];
int index, counter;
srand( time(0) );
for (index = 0; index < SIZE; index++) //random numbers
superArray[index] = rand() % 21 +1;
for (index = 0; index < SIZE; index++) //vertical print
{
printf("%8.f\n", superArray[index]);
}
printf("%8d\n\n", superArray[8]); //verify that array has random numbers
Run Code Online (Sandbox Code Playgroud)