473,320 Members | 1,957 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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;
Mar 20 '08 #1
4 6119
On Mar 20, 1:12 pm, June Lee <iiu...@yahoo.comwrote:
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.
Mar 20 '08 #2
gnuyuva wrote:
On Mar 20, 1:12 pm, June Lee <iiu...@yahoo.comwrote:
>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
Mar 20 '08 #3
Can i do also??

ne_uri uri = {0,0,0,0};
>typedef struct {
char *scheme;
char *host, *userinfo;
unsigned int port;
char *path, *query, *fragment;

} ne_uri;
>Which, BTW, means all the pointers are going to be null and 'port'
is going to be 0U.

V
Mar 20 '08 #4
June Lee wrote:
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
Mar 21 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Kai Wu | last post by:
#include <string.h> #include <fstream> #include <time.h> typedef unsigned char BYTE; struct Dex { BYTE status; struct timeval timestamp; }; int main(){
3
by: sathyashrayan | last post by:
The standard confirms that the following initialization of a struct struct node { --- --- } struct node var = {NULL};
20
by: fix | last post by:
Hi all, I feel unclear about what my code is doing, although it works but I am not sure if there is any possible bug, please help me to verify it. This is a trie node (just similar to tree nodes)...
6
by: Michael C | last post by:
Is it possible to use an ArrayList inside a struct? I keep running into a null reference exception when I try to Add to the ArrayList in the struct, and it won't let me initialize the ArrayList in...
3
by: c8prog | last post by:
I want to save integer value in array(int key) of struct array (Element key; public int link; Element(int init) { init = 0; key = new int; link = init; } };
5
by: Johs32 | last post by:
I have a struct "my_struct" and a function that as argument takes a pointer to this struct: struct my_struct{ struct my_struct *new; }; void my_func(struct my_struct *new); I have read...
4
by: Michael Brennan | last post by:
I have a menu_item structure containing an union. func is used if the menu item should use a callback, and submenu if a popupmen should be shown. struct menu_item { enum { function, popup }...
74
by: Zytan | last post by:
I have a struct constructor to initialize all of my private (or public readonly) fields. There still exists the default constructor that sets them all to zero. Is there a way to remove the...
3
by: Bob Altman | last post by:
Hi all, If I have a class that includes an instance of a struct as a member, how do I initialize that struct? I can't find a syntax for the constructor "initializer list" that works. For...
5
by: ssylee | last post by:
I'm not sure if I can initialize members of a struct the lazy way. For example, let's say I have a struct defined as below: typedef struct _ABC { BOOL A; BOOL B; BOOL C; } ABC;
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.