炫意html5
最早CSS3和HTML5移动技术网站之一

C struct

Above code works under Ubuntu20.
Can someone please help me to understand the struct variable ‘pandora’ declaration and initialization issue?

Specifically, the issue is from line3 to line9, what is this declaration style? Any reference would be better.
It seems that I declared a struct variable ‘pandora’ , and then assigned values to this variable.
I was confused on two variables ‘pandora’ did not make the gcc complier to issue error.

Many Thanks!

回答

Just found that this doesn’t compile:

struct Pandora {
	char *version;
	int status;
} pandora = {"some str", 0};

struct Pandora pandora = { "0.0.5", 4};

then I realized that line3 to line9 may works just like this:

struct Pandora pandora;
struct Pandora pandora = { "0.0.5", 4};

the first pandora appears as a decleration, while the second is as a definition.

炫意HTML5 » C struct

Java基础教程Android基础教程