I was writing a structure from a book, and then see how it does initialization.
I don’t get it, how he does that.
struct node
{
char target[50];
char stack[50];
char *s,*t;
int top;
}
Initialization function:
void init
{
p->top = -1;
strcpy(p->target,"");
strcpy(p->stack,"");
p-t = p->target;
p->s="";
}
So I want know how he is using strcpy to initialize an array or char.
He is not doing it. The statement
strcpy(p->target,"");does not initialize the 50 positions of the array. It just puts a 0 in the first position. (See this reference.)