ne_uri uri = {0};
typedef struct {
char *scheme;
char *host, *userinfo;
unsigned int port;
char *path, *query, *fragment;
} ne_uri;
It wont initialize the struct to NULL, but sets all struct elements
to
zero.
Which, BTW, means all the pointers are going to be null and 'port'
is going to be 0U.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
ne_uri uri = {0,0,0,0};
>> typedef struct {
>> char *scheme;
>> char *host, *userinfo;
>> unsigned int port;
>> char *path, *query, *fragment;
>>
>> } ne_uri;
Please don't top-post. Your replies belong following or interspersed
with properly trimmed quotes. See the majority of other posts in the
newsgroup, or the group FAQ list:
<http://www.parashift.com/c++-faq-lite/how-to-post.html>
Post rearranged to correct order.
> >> typedef struct {
> >> char *scheme;
> >> char *host, *userinfo;
> >> unsigned int port;
> >> char *path, *query, *fragment;
> > >
> >> } ne_uri;
> > Can i do also??
> ne_uri uri = {0,0,0,0};
Yes. This will explicitly set scheme, host, userinfo, and port to 0.
The remainder of the members will be zero-initialized. That doesn't
really buy you anything. A full listing might, for documentation
reasons, but the {0} form is idiomatic.
Brian
Yes. In C++ you can actually do just
ne_uri uri = {};
with the same effect.
--
Best regards,
Andrey Tarasevich
It is mostly idiomatic in C. It is not as "idiomatic" in C++ since it will not
work when the first field cannot be initialized with explicit integral 0, but
still can be implicitly zero-initialized (field of enum type, for example). For
this reason, in C++ the corresponding idiomatic initializer is '{}'.