Hi, guys, I somewhere read "You cannot initialize a structure like that at run time."
example:
But if you want to assign values at run time then you have to do it manually like:
i tried in internet but am unable to know the differences. I want to know the difference between those two in terms of run time and compile time.
Please explain me also the below one. Is this run time or compile time? How does we actually decide which is run time and which is compile time!
example:
Code:
struct item_info
{
char itemname[15];
int quantity;
float retail;
float wholesale;
}item[NOOFITEM];
int main()
{
item[0]={"rice",10,40,30};
item[1]={"sugar",10,40,30};
item[2]={"soap",10,40,30};
}
Code:
strcpy(item[0].itemname, "rice"); item[0].quantity = 10; item[0].retail = 40; item[0].wholesale = 30;
Please explain me also the below one. Is this run time or compile time? How does we actually decide which is run time and which is compile time!
Code:
struct item_info
{
char itemname[15];
int quantity;
float retail;
float wholesale;
//int quatityonorder;
}item[NOOFITEM] =
{
{"rice",10,40,30},
{"sugar",10,40,30},
{"soap",10,40,30}
};
Comment