All I'm trying to do is initialize my array to all 0s in C, but my compiler keeps giving me errors (and the errors aren't helpful). The array has 24 entries and the values are floating point values.
main()
{
/* Array of users arrival & departure time */
float user_queue[24];
/* Initialize queue to 0 */
int i;
for(i = 0; i < 24; i++)
{
user_queue[i] = 0.0;
}
/* Simulation time */
float time = 0;
The compiler is giving me an error on the "float time" line. The error goes away if I remove my for loop.
syntax error : missing ; before type
You may not be allowed to declare variables after you have already used expressions. Try moving the declaration of time to the top:
main()
{
/* Array of users arrival & departure time */
float time, user_queue[24];
/* Initialize queue to 0 */
int i;
for(i = 0; i < 24; i++)
{
user_queue[i] = 0.0;
}
/* Simulation time */
time = 0;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With