Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old March 20th, 2008, 08:15 AM
June Lee
Guest
 
Posts: n/a
Default 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;
  #2  
Old March 20th, 2008, 09:35 AM
gnuyuva
Guest
 
Posts: n/a
Default 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.
  #3  
Old March 20th, 2008, 02:15 PM
Victor Bazarov
Guest
 
Posts: n/a
Default 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


  #4  
Old March 20th, 2008, 10:05 PM
June Lee
Guest
 
Posts: n/a
Default 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
  #5  
Old March 21st, 2008, 04:05 AM
Andrey Tarasevich
Guest
 
Posts: n/a
Default 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
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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.
Post your question now . . .
It's fast and it's free

Popular Articles