Orange wrote:
hi,
How to initialize the data variable.
typedef struct
{
long len;
BYTE data[];
}tag;
Eventhough i know it is error, i tried like this
t.data = "text";
help me to solve this problem
urs,
Orange
hi
first of all I want to know about BYTE type.
anyways as u are trying to initialize it with "text" so I assume it as
char pointer.
so ur problem is
typedef struct
{
long len;
char* data;
}tag;
now u want to initialize member variable data.
do u know y ur method is wrong......?????
bcos initialization can be done only when we are defineing the
variable.
so to initialize data member variable u need to perform
struct tag variable = { 12345, "text"};
this is the way to initialize variable.
Please let you clear urself that initialization can be done only at the
defining time of variable.
like
struct tag t;
t.data = "text";
is not initializing it is a sort of assigning, which is also wrong.
you can assign only address to pointer type variables with some
exceptions.