Is it normal for a int in a array struct to be 0?

Viewed 29

new to code. Currently doing a project which I'll need to use a array of structs. I have something like this as a sample:

#include <stdio.h>

  struct InfoCar
   {
     int OnOff;
     char CarNumber[9];
   }CarData[10];    

int main(void) 
{

int i;

    for(i=0;i<10;i++)
    { 
      printf("%d", CarData[i].OnOff); 
    }


    return 0;
}

The thing is, from what I've learned and searched all int without value would store a random value, but this one is showing all output CarData[i].OnOff to be 0. Am I wrong or is this due to the struct array ?

0 Answers
Related