I have defined a struct like this
Struct rectangle{
int x;
int y;
int z;
};
and then in my main method, i will be assigning the variables:
void main(int argc, const char *argv[])
{
for(i=0;i<20;i++)
{
rectangle[i].x = 20;
rectangle[i].y = 10;
}
}
But I wont be assigning the ‘z’ variable of the struct anytime. Am i allowed to do this?
hope i am not asking something very dumb!!
Thanks in advance!
Yes, that’s fine. Any attempt to use
rectangle[i].zwill result in undefined behaviour,* but that’s not a problem so long as you don’t try to use it.* Unless
rectangleis declared as a global/static array, in which case all its members are implicitly initialized to zero.