
March 20th, 2008, 08:15 AM
| | | struct initialize
what is it means by {0}, is that means initialize a struct to NULL?
ne_uri uri = {0};
typedef struct {
char *scheme;
char *host, *userinfo;
unsigned int port;
char *path, *query, *fragment;
} ne_uri; | 
March 20th, 2008, 09:35 AM
| | | Re: struct initialize
On Mar 20, 1:12 pm, June Lee <iiu...@yahoo.comwrote: Quote:
what is it means by {0}, is that means initialize a struct to NULL?
>
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. | 
March 20th, 2008, 02:15 PM
| | | Re: struct initialize
gnuyuva wrote: Quote:
On Mar 20, 1:12 pm, June Lee <iiu...@yahoo.comwrote: Quote:
>what is it means by {0}, is that means initialize a struct to NULL?
>>
>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 | 
March 20th, 2008, 10:05 PM
| | | Re: struct initialize
Can i do also??
ne_uri uri = {0,0,0,0}; Quote: Quote:
>typedef struct {
> char *scheme;
> char *host, *userinfo;
> unsigned int port;
> char *path, *query, *fragment;
>>
>} ne_uri;
| | Quote:
>Which, BTW, means all the pointers are going to be null and 'port'
>is going to be 0U.
>
>V
| | 
March 21st, 2008, 04:05 AM
| | | Re: struct initialize
June Lee wrote: Quote:
Can i do also??
>
ne_uri uri = {0,0,0,0};
...
| Yes. In C++ you can actually do just
ne_uri uri = {};
with the same effect.
--
Best regards,
Andrey Tarasevich |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over network members.
|